-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: improve disable AsyncLocalStorage test #31998
test: improve disable AsyncLocalStorage test #31998
Conversation
Can we fast-track this one? It just adds an assertion to a test. |
Looks like tests are flaky. As far as I can see, failed tests are not related with this PR. |
@puzpuzpuz something went wrong in CI, I restarted it |
There's actually a deeper issue than that. 'use strict';
require('../common');
const assert = require('assert');
const { AsyncLocalStorage } = require('async_hooks');
const asyncLocalStorage = new AsyncLocalStorage();
const store = {};
asyncLocalStorage.runSyncAndReturn(store, () => {
process.nextTick(() => {
// This will fail because the second `runSyncAndReturn` re-enabled the storage
// between when it was disabled and when the `nextTick` callback runs.
assert.strictEqual(asyncLocalStorage.getStore(), undefined);
});
asyncLocalStorage.disable();
});
asyncLocalStorage.runSyncAndReturn(store, () => {
assert.strictEqual(asyncLocalStorage.getStore(), store);
}); In this example, they are in the same sync tick, but imagine two runs from two separate http requests with a less immediate async task like a |
Your snippet shows expected behavior which is described in the doc: https://github.com/nodejs/node/blob/311e12b96201c01d6c66c800d8cfc59ebf9bc4ae/doc/api/async_hooks.md#asynclocalstoragedisable This behavior (and the general approach for In any case, this discussion seems to be unrelated with changes from this PR and should be moved into a GH issue or a separate PR. WDYT? |
Ah, hmm...okay. I must have missed that. Seems like very strange behaviour to me though. It makes it impossible to actually fully disable the storage. 😕 Anyway, yes, we can take this concern elsewhere. |
Another flaky CI run 😢. Could someone re-run it? |
6387b29
to
d0f9175
Compare
I have rebased over the latest |
PR-URL: #31998 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in 68e36ad |
PR-URL: #31998 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]> Reviewed-By: James M Snell <[email protected]>
v12 backport: #32318 |
PR-URL: nodejs#31998 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: nodejs#31998 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #31998 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Vladimir de Turckheim <[email protected]> Reviewed-By: James M Snell <[email protected]>
Improves
test-async-local-storage-enable-disable.js
test, as it wasn't covering.disable()
method's behavior as it should. See #31950 (comment) for more details.cc @Qard @vdeturckheim
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes