unsphere
unsphere4mo ago

How to use Buffer in httpRouter?

Some npm packages I need rely on Buffer and I am already using "use node" for convexAuth ConvexCredentials that is working fine. But then I get the following error:
InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Failed to analyze http.js: Uncaught ReferenceError: Buffer is not defined
at node_modules/@ton/core/dist/boc/BitString.js (../../node_modules/@ton/core/dist/boc/BitString.js:167:53)
at __require2 (convex:/_deps/225NMHCD.js:16:50)
at node_modules/@ton/core/dist/boc/BitBuilder.js (../../node_modules/@ton/core/dist/boc/BitBuilder.js:16:0)
at __require2 (convex:/_deps/225NMHCD.js:16:50)
at node_modules/@ton/core/dist/boc/Builder.js (../../node_modules/@ton/core/dist/boc/Builder.js:11:15)
at __require2 (convex:/_deps/225NMHCD.js:16:50)
at node_modules/@ton/core/dist/address/contractAddress.js (../../node_modules/@ton/core/dist/address/contractAddress.js:11:6)
at __require2 (convex:/_deps/225NMHCD.js:16:50)
at node_modules/@ton/core/dist/index.js (../../node_modules/@ton/core/dist/index.js:33:22)
at __require2 (convex:/_deps/225NMHCD.js:16:50)
InvalidModules: Hit an error while pushing:
Loading the pushed modules encountered the following
error:
Failed to analyze http.js: Uncaught ReferenceError: Buffer is not defined
at node_modules/@ton/core/dist/boc/BitString.js (../../node_modules/@ton/core/dist/boc/BitString.js:167:53)
at __require2 (convex:/_deps/225NMHCD.js:16:50)
at node_modules/@ton/core/dist/boc/BitBuilder.js (../../node_modules/@ton/core/dist/boc/BitBuilder.js:16:0)
at __require2 (convex:/_deps/225NMHCD.js:16:50)
at node_modules/@ton/core/dist/boc/Builder.js (../../node_modules/@ton/core/dist/boc/Builder.js:11:15)
at __require2 (convex:/_deps/225NMHCD.js:16:50)
at node_modules/@ton/core/dist/address/contractAddress.js (../../node_modules/@ton/core/dist/address/contractAddress.js:11:6)
at __require2 (convex:/_deps/225NMHCD.js:16:50)
at node_modules/@ton/core/dist/index.js (../../node_modules/@ton/core/dist/index.js:33:22)
at __require2 (convex:/_deps/225NMHCD.js:16:50)
Using "use node" inside of the httpRouter file where the ConvexAuth http actions will be consumed is not allowed.
"use node" directive is not allowed for http.ts.
"use node" directive is not allowed for http.ts.
Any idea?
3 Replies
Convex Bot
Convex Bot4mo ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
ballingt
ballingt4mo ago
You'll need to define the HTTP endpoints in a non-"use node" convex/http.ts file and call ctx.runAction() to call out to the Node.js actions.
unsphere
unsphereOP4mo ago
ah great. thats it. thank you tom!

Did you find this page helpful?