-
Notifications
You must be signed in to change notification settings - Fork 70
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
Nodejs StartSocketConnection is not a function #3195
Comments
Hi @phawxby :) |
Having all those: -rw-r--r--@ 1 paulhawxby staff 1852129 Jan 1 1980 eventData.js
-rw-r--r--@ 1 paulhawxby staff 4081730 Feb 17 13:24 eventData.js.map
-rwxr-xr-x@ 1 paulhawxby staff 4800864 Feb 17 13:24 glide-rs.darwin-arm64.node
-rwxr-xr-x@ 1 paulhawxby staff 4949752 Feb 17 13:24 glide-rs.linux-arm64-gnu.node
-rwxr-xr-x@ 1 paulhawxby staff 4986584 Feb 17 13:24 glide-rs.linux-arm64-musl.node
-rwxr-xr-x@ 1 paulhawxby staff 5756848 Feb 17 13:24 glide-rs.linux-x64-gnu.node
-rwxr-xr-x@ 1 paulhawxby staff 5752728 Feb 17 13:24 glide-rs.linux-x64-musl.node Means that you are bundling them for browser env, while those are native packages, and you can't bundle all, they have to run on node env only. Or deno/bun etc., but on server env. Your severless.yml file should look something like this: service: "esbuild-with-glide"
provider:
name: aws
runtime: nodejs20.x
build:
esbuild: false
plugins:
- serverless-esbuild
custom:
esbuild:
bundle: true
minify: true
sourcemap: true
target: node20
platform: node
packager: 'npm'
keepOutputDirectory: false
loader:
".node": "copy"
external:
- "@valkey/valkey-glide"
- "@valkey/valkey-glide-linux-musl-x64"
- "@valkey/valkey-glide-linux-x64"
- "glide-rs"
exclude:
- 'node_modules/@valkey/valkey-glide-linux-musl-x64/*'
tsconfig: './tsconfig.json'
outdir: '.esbuild/.serverless'
functions:
hello:
handler: index.handler
package:
individually: true |
@raczmarton do you have the same issue? |
@avifenesh thanks for the quick response. This is our esbuild config.
I'll add glide to the externals and set the pipeline going and get back to you. |
@phawxby Thanks. Note that if you build on ARM architecture, and deploy to Lambda, which is x86, you are going to have it fail.
If this is your case, please let me know and ill give you a workaround. |
@avifenesh ah so our monorepo has a mixture of x86 and ARM lambda's but we have general purpose build process we use for everything that runs on x86 in CircleCI. What do you suggest? |
The easiest way is to download separately the parts with Rust: // For ARM
"@valkey/valkey-glide-linux-arm64": "^1.2.1",
// you will have those anyway when you will install glide on x86:
"@valkey/valkey-glide-linux-x64": "^1.2.1",
// You will have it, but you dont need it unless you run on alpine:
"@valkey/valkey-glide-linux-musl-x64": "^1.2.1", Then on each platform all of them will be available, and the code is knowing to choose base on the env it runs on.
And vice versa. If you absolutely don't have how to separate, have both |
@avifenesh that's what I thought we were doing with this.
I was just including all the variants so that the code to decide which to import base on the environment |
That's fine, it works, but it's heavy, that's all. It's heavy compared to node packages, not GB. |
@avifenesh so that's the thing then. We're including all the native |
Want to jump to valkey slack to have faster debugging? |
For public awareness of what this specific issue appears to come down to. Valkey glide is structured in such a way that there is an entry package which based on the architecture loads specific sub dependency packages, for example @valkey/valkey-glide-linux-arm64. Unfortunately those sub dependency packages also include the full JS wrapper around the rust native binary and not just the binary. This means that if you're trying to bundle the js with esbuild (and especially in our case where we want to bundle for multiple architectures at the same time) you end up with the same wrapper code bundled in multiple times which inflates the output bundle size and also appears to break things. There are possible workarounds with lambda layering, manual esbuild steps to copy files around, but that would require a lot of rework of our build pipeline. Also @avifenesh has had success using serverless-esbuild. It's worth noting most other libraries where native binaries are required are not structured this way, the arch specific binary is in a package on its own and the wrapper code it self acts as the parent entry package. |
Adding some context - If you use more than one target, you need to install the specific The restructuring is under development and likely to be released soon. |
@Muhammad-awawdi-amazon Another issue that will benefit from the restructuring. No pressure 😝 |
Inquiry
We're using
esbuild
to bundle and minify handler code for AWS Lambdas producing this kind of output.When executed on AWS we get the following error.
I absolutely cannot figure out where this error is coming from.
Language
Typescript
Language Version
5.1.6
Engine Version
Node 22
Operating System
ARM & x86
Additional Technical Information
No response
The text was updated successfully, but these errors were encountered: