Skip to content

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

Open
@justin-masse

Description

@justin-masse

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,
      },
    )
  1. Deploy code in a lambda function to Node18 runtime
  2. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.p2This is a standard priority issuepending-releaseThis issue will be fixed by an approved PR that hasn't been released yet.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions