Could no resolve "util"
How does the convex backend actually run ? Does it use node / can I use packages intended for node and how?
45 Replies
The "use node" thing is on the right track, every file in the convex directory that imports (or imports a file that imports, etc.) "util" or any other Node.js builtin needs to have "use node" at the top. To narrow down which file it is you can try removing files to see when the problem disappears. It looks like it's something that imports @tensorflow
External packages the @v links to are mostly a performance optimization, you'll still need to avoid importing from "use node" files from non-"use node" files.
"util" was just an example, I
I'm only trying to import tensorflow
but it depends on many packages, and so far every single tf dependency is giving me that error
I thought using an external package would fix dynamic imports, my bad on that(because I thought that might be the issue)
it's too big to be one apparently
Yeah sounds like they all need to be imported only from "use node" convex files, and you can't import anything from those "use node" files from non-"use node" files
All the "use node" files get bundled together and all the non-"use node" files get bundled together (into separate bundles, but it's the same bundle process" and if you import a "use node" file from one of the non-"use node" files you'll see these errors
I'm only importing it from filers with "use node"
You might be importing one of those files from a non-"use node" file
We may have some linters before long for this sort of thing, alerting if you every import a "use node" from a non-"use node"
At the moment the only file tensorflow is imported it has "use node" and all it does is import tf. That file is not imported anywhere else
At least not that I can see
What's the name of that file, try searching your project files ((ctrl/cmd)-shift-f in VSCode) for that filename
Off topic, that profile photo looks dope @Lightwaves
lol thanks, i've had it for years, I can't remember where it's from
Okay so, it's just named
tf_model.ts
Here it is
This actually works
but
if I uncoment the "build model" function
then it doesn't workI get

Are you only installing packages that are being used
cause if so that's pretty cool
Yeah, that's an esbuild thing, it does tree-shaking
And nothing else imports from tf_model.ts?
Oh wait, I thought you had a different error
neat, anyways, removing that convex.json file, when I uncomment the function I get these
I don't kno wwhy it's only these

This error is about not being able to mark this as external
yes I was just saying it was weird that it only happened when i uncomment the function lol but yeah Ive removed that file
Hm I wonder what library requires this @mapbox/node-pre-gyp thing, whatever's using that needs to be marked as external
tensorflow does
Rip
ah hm, anything involving binaries like that shoudl be an external dependency, because you can't bundle binaries
but if I mark it as external it's apparently too big
You may be out of luck for this library for now, hm I wonder if anyone else has used it
I thought that's what external was for
Is this limit configurable with convex-backend
🥲 RIp to my hackathon project
@Tom
I'll try with the non-node package
Or would it have to be rebuilt. Not that is an issue but it would be easier.
Oh there's a non-node package! Yeah use that
Likely yes? @v check the code
This is an issue with what we can deploy to AWS Lambda
Hmm okay
😔 well the non-node package works, obviously, unfortunately this make everything much slower lol. I know tf-node is a pain of a package though, because it require this gyp library and python. I just hoped it would work because the regular package is the opposite of performant
Xd
nice to be bale to use any tensorflow though
I wonder if the CLI also checks the package size too
Shoot, yeah sounds like you're stuck deploying a container to deploy that code @Lightwaves
I don't think the the external packages check doesn't happen locally in the CLI, I think we have to actually install the packages on AWS Lambda?
That would be better
I just wonder how different the behavior is for the local node executor
I'ma check
Sike

-_-
Does GitHub oauth still work I wonder
Yes
heh, github works fine for me :p
Lucky ahhh
Haha nah ittle be back soon
Yup back
GitHub
convex-backend/crates/model/src/source_packages/types.rs at d1bfe3e...
Open source single-machine version of the Convex backend - get-convex/convex-backend
Ah ok, yeah is designed specificaly for AWS Lambda
i know but i wanted to see what would happen
is that limit still here on selfhosting ?
i can see later on linux
im just messing around
my pc too dookie to search for scalars i guess. it takes ages

yeah i know nothing about lambda