Skip to content

feat(node): Auto-select best AsyncContextStrategy for Node.js version#7804

Merged
AbhiPrasad merged 2 commits intogetsentry:developfrom
timfish:feat/auto-select-async-strategy
Apr 11, 2023
Merged

feat(node): Auto-select best AsyncContextStrategy for Node.js version#7804
AbhiPrasad merged 2 commits intogetsentry:developfrom
timfish:feat/auto-select-async-strategy

Conversation

@timfish
Copy link
Copy Markdown
Collaborator

@timfish timfish commented Apr 11, 2023

Automatically select the best AsyncContextStrategy for the Node.js version.

  • Node.js >= 14 uses AsyncLocalStorage
  • Node.js < 14 uses domains

@timfish timfish mentioned this pull request Apr 11, 2023
9 tasks
* Node.js >= 14 uses AsyncLocalStorage
* Node.js < 14 uses domains
*/
export function setNodeAsyncContextStrategy(): void {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we get a sanity check test for this?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you mean? A test that checks that the version detection is working?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, but now that I think about it, it's maybe too complicated. We can add one any time later on.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm surprised that there was no TypeScript or lint error from using if (NODE_VERSION >= 14)!

Co-authored-by: Abhijeet Prasad <devabhiprasad@gmail.com>
Copy link
Copy Markdown
Contributor

@AbhiPrasad AbhiPrasad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@AbhiPrasad AbhiPrasad merged commit 4856685 into getsentry:develop Apr 11, 2023
@timfish timfish deleted the feat/auto-select-async-strategy branch April 11, 2023 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants