Open joonseokhu opened 1 week ago
The result of this code below
const { AsyncLocalStorage } = require('node:async_hooks'); const asyncLocalStorage = new AsyncLocalStorage(); const store = { id: 2 }; try { asyncLocalStorage.run(store, () => { const store1 = asyncLocalStorage.getStore(); // Returns the store object console.log({ store1 }) setTimeout(() => { const store2 = asyncLocalStorage.getStore(); // Returns the store object console.log({ store2 }) }, 200); throw new Error(); }); } catch (e) { const store3 = asyncLocalStorage.getStore(); // Returns undefined console.log({ store3 }) // The error will be caught here }
should be this:
{ store1: { id: 2 } } { store3: undefined } { store2: { id: 2 } }
but, the actual result from RunJS was this:
{ store1: { id: 2 } } { store3: undefined } { store2: undefined }
The code that I wrote was almost same as that in Nodejs Document: https://nodejs.org/api/async_context.html#asynclocalstoragerunstore-callback-args
@joonseokhu, thanks for raising this. I've taken a quick look, and it seems that this may be an upstream bug in Electron.
The result of this code below
should be this:
but, the actual result from RunJS was this:
The code that I wrote was almost same as that in Nodejs Document: https://nodejs.org/api/async_context.html#asynclocalstoragerunstore-callback-args