Skip to content

Instantly share code, notes, and snippets.

@Aschen
Created May 4, 2020 09:58
Show Gist options
  • Save Aschen/52ff5e929150f97c89d8ad5eaa840968 to your computer and use it in GitHub Desktop.
Save Aschen/52ff5e929150f97c89d8ad5eaa840968 to your computer and use it in GitHub Desktop.
const { AsyncLocalStorage } = require('async_hooks');
const asyncLocalStorage = new AsyncLocalStorage();
app.get('/', (request, response) => {
const requestId = uuid();
asyncLocalStorage.run(requestId, async () => {
// entering asynchronous context
log('Start processing');
await emailService.notify(request.body.emails);
response.writeHead(200);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment