Skip to content
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

fix use node: protocol for async_hooks import #52

Merged
merged 2 commits into from
Feb 6, 2025

Conversation

wootsbot
Copy link
Contributor

This PR updates the import of the async_hooks module to use the node: protocol, as recommended by Node.js. This change aligns with best practices and ensures better compatibility and clarity in the codebase.

Changes

  • Updated import { AsyncLocalStorage } from "async_hooks"; to import { AsyncLocalStorage } from "node:async_hooks";.

References

close #51

Copy link

vercel bot commented Jan 30, 2025

@wootsbot is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

@erik-nilcoast
Copy link

erik-nilcoast commented Feb 5, 2025

nilcoast#1 trying out the same thing here.

Copy link

vercel bot commented Feb 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
summer-sale ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 6, 2025 0:47am

@dferber90 dferber90 merged commit 6784f10 into vercel:main Feb 6, 2025
4 of 5 checks passed
dferber90 added a commit that referenced this pull request Feb 7, 2025
@erik-nilcoast
Copy link

This change allowed for backfilling with a stub (via some webpack aliasing), which I did so that it will work client side, but if the expectation is that this is ALWAYS fed from server side props then this library won't really work for the rare times I need client side hooks for behavior.

@dferber90
Copy link
Collaborator

The expectation is that the Flags SDK is used server-side. This is necessary to keep flags confidential, to avoid layout shift, and to be able to override flags using an encrypted cookie.

If you need the value of the flags on the client you can pass their values as props. You can set up a context from a layout such that you can access the flags client-side in case multiple flags need it. You can also use the precompute pattern to make flags available to the whole application. The best approach depends on the type of the application you are building.

@erik-nilcoast
Copy link

erik-nilcoast commented Feb 12, 2025

@dferber90 yup, that's clear. My flags aren't secret and don't cause shift, but I get ya. For me a stateless solution worked best for now. I'll likely still bootstrap with vercel k/v until the docs and implementation on the vercel-sdk bake a bit more.

You really should consider putting that server side caveat in the notes. Maybe it's clearer to others?

@wootsbot wootsbot deleted the fix-cant-resolve-async-hooks branch February 13, 2025 02:31
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.

Module not found: Can't resolve 'async_hooks'
3 participants