#Unsupported scheme (node) in node:async_hooks

1 messages · Page 1 of 1 (latest)

brisk nexus
#

[CONVEX H(GET /api/auth/get-session)] Unsupported scheme (node) in node:async_hooks

noble valeBOT
#

Hi @brisk nexus. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The error message Unsupported scheme (node) in node:async_hooks indicates that your code (or a dependency) is trying to import a Node.js built-in module (node:async_hooks) in an environment that does not support Node.js APIs. In Convex, only actions in files with the "use node" directive can use Node.js built-ins, and even then, there are limitations.

From the knowledge sources:

  • If you try to use Node.js-specific modules (like node:async_hooks) in a file that is not marked with "use node", Convex will throw an error. You must move any code that requires Node.js APIs into a separate file with the "use node" directive at the top. Only actions are allowed in such files, not queries or mutations. Also, files without "use node" cannot import from files with "use node" and vice versa. This is a strict separation enforced by Convex's bundler and runtime. See more details here: Functions > Runtimes > Node.js runtime.

  • Some packages (like Inngest or certain auth libraries) may use dynamic imports or require Node.js built-ins internally. If these are used in a Convex function that is not an action in a "use node" file, you will get errors like the one you are seeing. Even with "use node", dynamic requires can be problematic due to how Convex bundles code and the limitations of the runtime. See the discussion here: Help with writing Inngest http action - dynamic Node require.

#

What you can do:

  • Move any code that requires Node.js built-ins into a separate file with "use node" at the top, and ensure it is only used as an action.
  • If you are using a third-party library that requires Node.js built-ins, and you cannot move it into a "use node" action, you may not be able to use it with Convex unless the library provides a browser-compatible build.
  • If you are deploying to an environment that is not Node.js (like Cloudflare Workers), you cannot use Node.js built-ins at all.

If you need to use a library that is not compatible, you may need to refactor your code or use a different approach.

If you have a specific code snippet or use case, please share it for more targeted advice.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: