awslabs / awslabs/aws-crt-nodejs

Node binaries not loading from binding.js when hoisted to root of node_modules

Open
#523 9 comments 3 reactions 0 assignees View on GitHub
bug p2 pending-release
Dominant language
TypeScript
Stars
43
Forks
32
Avg merge
1d 17h
Merged PRs (30d)
1

Description

### Describe the bug

When using @aws-sdk/signature-v4-crt it is getting an error that AWS CRT binary not present in any of the following locations:

I have verified the aws-crt package is present and I can see the binary in bin/linux-x64-glibc as aws-crt-nodejs.node. The problem is that it gets hoisted to the top level of node_modules by yarn instead of living under sigv4 package.

Runtime is AWS Lambda Node18

### Expected Behavior

Not to get this error

### Current Behavior

When using sigv4 CRT signing methods it gives error:

```
"Error: AWS CRT binary not present in any of the following locations:",
"\t/bin/linux-x64-glibc/aws-crt-nodejs",
" at node_modules/aws-crt/dist/native/binding.js (/var/task/index.js:781126:13)",
" at __require (/var/task/index.js:12:51)",
" at node_modules/aws-crt/dist/native/auth.js (/var/task/index.js:781569:38)",
" at __require (/var/task/index.js:12:51)",
" at node_modules/aws-crt/dist/index.js (/var/task/index.js:785169:30)",
" at __require (/var/task/index.js:12:51)",
" at node_modules/@aws-sdk/signature-v4-crt/dist-cjs/CrtSignerV4.js (/var/task/index.js:981809:21)",
" at __require (/var/task/index.js:12:51)",
" at node_modules/@aws-sdk/signature-v4-crt/dist-cjs/index.js (/var/task/index.js:981939:25)",
" at __require (/var/task/index.js:12:51)"
```

### Reproduction Steps

1. Install @aws-sdk/signature-v4-crt
2. use signature-v4-crt for exmaple:
```
const sigV4 = new CrtSignerV4({
credentials: options.sigv4.credentials,
region: '*',
service: options.sigv4.service,
sha256: Sha256
})

const { method, headers, body } = await sigV4.sign(
{
method: requestInit.method,
headers: requestInit.headers,
protocol: 'https',
hostname: url.hostname,
path: `${url.pathname}?${url.search}`,
body: requestInit.body as string | undefined,
},
)
```
3. Deploy code in a lambda function to Node18 runtime
4. execute and it fails with the error above.

### Possible Solution

_No response_

### Additional Information/Context

_No response_

### aws-crt-nodejs version used

1.18.3

### nodejs version used

18

### Operating System and version

linux2

Contributor guide

Open the contributing guide

Research direction

Start with dist/native/binding.js and the aws-crt package layout shown in the error, then reproduce the hoisted node_modules layout with @aws-sdk/signature-v4-crt under Node 18 in Lambda. Trace how binding.js locates aws-crt-nodejs.node under the root-hoisted package; done means the reproduction loads the binary without the missing-binary error.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.