Skip to content

Commit

Permalink
Regression test of the retrieval of AsyncLocalStorage after await.
Browse files Browse the repository at this point in the history
  • Loading branch information
iamstolis committed Oct 9, 2023
1 parent f5cf69d commit 4d8a0bf
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions graal-nodejs/test/graal/unit/other.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
* SOFTWARE.
*/

var async_hooks = require('async_hooks');
var assert = require('assert');
var fs = require('fs');
var module = require('./_unit');
Expand Down Expand Up @@ -110,4 +111,19 @@ describe('Other', function () {
it('should not define FinalizationGroup', function () {
assert.strictEqual(global.FinalizationGroup, undefined);
});
it('should keep local storage after await', function(done) {
const { AsyncLocalStorage } = async_hooks;
const asyncLocalStorage = new AsyncLocalStorage();

asyncLocalStorage.run({id: 42}, async () => {
try {
assert.strictEqual(asyncLocalStorage.getStore().id, 42);
await 211;
assert.strictEqual(asyncLocalStorage.getStore().id, 42);
done();
} catch (err) {
done(err);
}
});
});
});

0 comments on commit 4d8a0bf

Please sign in to comment.