aws-sdk-js-v3 icon indicating copy to clipboard operation
aws-sdk-js-v3 copied to clipboard

3.178.0 may break @aws-sdk/s3-request-presigner getSignedUrl

Open bmccann36 opened this issue 1 year ago • 5 comments

Checkboxes for prior research

Describe the bug

3 hours ago there was a release to version 3.178.0. We are using npm i not ci in our pipeline so a newer version was installed. We did not change anything in our code but after the new build we started seeing this when our code tried to execute import {getSignedUrl} from '@aws-sdk/s3-request-presigner'

2022-09-23T21:25:54.847Z	undefined	ERROR	Uncaught Exception 	{
    "errorType": "Runtime.ImportModuleError",
    "errorMessage": "Error: Cannot find module '@aws-sdk/middleware-endpoint'\nRequire stack:\n- /opt/nodejs/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/getSignedUrl.js\n- /opt/nodejs/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/index.js\n- /var/task/api/services/businessLogic/asset-logic.js\n- /var/task/api/services/businessLogic/inbound-ticket/inbound-ticket-logic.js\n- /var/task/handlers/inbound-ticket-handler.js\n- /var/runtime/UserFunction.js\n- /var/runtime/Runtime.js\n- /var/runtime/index.js",
    "stack": [
        "Runtime.ImportModuleError: Error: Cannot find module '@aws-sdk/middleware-endpoint'",
        "Require stack:",
        "- /opt/nodejs/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/getSignedUrl.js",
        "- /opt/nodejs/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/index.js",

If we change our package.json from "@aws-sdk/s3-request-presigner": "^3.178.0" => "@aws-sdk/s3-request-presigner": "3.67.0" it fixes the issue

SDK version number

@aws-sdk/[email protected]

Which JavaScript Runtime is this issue in?

Node.js

Details of the browser/Node.js/ReactNative version

node 14 on AWS Lambda

Reproduction Steps

  • make a typescript node project
  • install dependencies
  • execute a file with these contents in node
import {getSignedUrl} from '@aws-sdk/s3-request-presigner';
import {GetObjectCommand, S3Client,} from '@aws-sdk/client-s3';
const client = new S3Client({});
const command = new GetObjectCommand({Key: '123', Bucket: 'abc'});
getSignedUrl(client, command).then(console.log)

Observed Behavior

➜  scratch node --version
v16.17.0
➜  scratch node scratch.js
node:internal/modules/cjs/loader:959
  throw err;
  ^

Error: Cannot find module '@aws-sdk/middleware-endpoint'
Require stack:
- /Users/brianmccann/Desktop/scratch/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/getSignedUrl.js
- /Users/brianmccann/Desktop/scratch/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/index.js
- /Users/brianmccann/Desktop/scratch/scratch.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.Module._load (node:internal/modules/cjs/loader:804:27)
    at Module.require (node:internal/modules/cjs/loader:1028:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/brianmccann/Desktop/scratch/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/getSignedUrl.js:4:31)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/brianmccann/Desktop/scratch/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/getSignedUrl.js',
    '/Users/brianmccann/Desktop/scratch/node_modules/@aws-sdk/s3-request-presigner/dist-cjs/index.js',
    '/Users/brianmccann/Desktop/scratch/scratch.js'
  ]
}

Expected Behavior

I am able to call getSignedUrl

Possible Solution

No response

Additional Information/Context

No response

bmccann36 avatar Sep 23 '22 23:09 bmccann36

looks like this is a dupe of https://github.com/aws/aws-sdk-js-v3/issues/3981

bmccann36 avatar Sep 23 '22 23:09 bmccann36

Even i am facing the same issue. Could anyone resolve this

ahmed-sharief5 avatar Sep 24 '22 17:09 ahmed-sharief5

as a workaround while the issue is fixed, we've added @aws-sdk/middleware-endpoint to our package.json and that solved the problem

mdesousa avatar Sep 24 '22 18:09 mdesousa

as a workaround while the issue is fixed, we've added @aws-sdk/middleware-endpoint to our package.json and that solved the problem

I tried this and discovered other packages also seem to be missing from dep tree.

ianwremmel avatar Sep 24 '22 18:09 ianwremmel

as a workaround while the issue is fixed, we've added @aws-sdk/middleware-endpoint to our package.json and that solved the problem

mdesousa's workaround works.

appleinautumn avatar Sep 25 '22 19:09 appleinautumn

This is exactly what I got today. Change to older version fix this problem.

thangchinh avatar Sep 26 '22 03:09 thangchinh

Even after installing the package separately it shows Cannot find module. Could the owner fix this issue please. Its causing our application to down from 3 days

ahmed-sharief5 avatar Sep 26 '22 05:09 ahmed-sharief5

@ahmed-sharief5 try using an older version.

aitchkhan avatar Sep 26 '22 13:09 aitchkhan

@aitchkhan Please let me know the version number

ahmed-sharief5 avatar Sep 26 '22 13:09 ahmed-sharief5

Hi @bmccann36, thanks for opening this issue. I can confirm this is an issue and we will work on getting this fixed as soon as possible. In the meantime we have two workarounds. Please see below:

  • The first one is to use the version 3.173.0 which does not contains this bug:
  • The second workaround is to install the missing dependency manually:
    • yarn add @aws-sdk/middleware-endpoint

I will use this thread to provide updates accordingly.

Thanks!

yenfryherrerafeliz avatar Sep 26 '22 13:09 yenfryherrerafeliz

I have Nodejs code running on aws fargate container. What I did just add one logic, tested code and pushed code to github. And AWS started pipeline process. When deployment failed I checked cloud watch to know why its failed. So I found that my Nodejs code requrire one package to run @aws-sdk/middleware-endpoint. When I tested my nodejs code in my local system I didn't received any such error. After reading this error I installed package @aws-sdk/middleware-endpoint and my server is running well. I am willing to know why @aws-sdk/middleware-endpoint is required suddenly. Although previously my all apis are working fine in same aws server, But today I saw requirement of @aws-sdk/middleware-endpoint.

Anyone can help me what is need of @aws-sdk/middleware-endpoint? 1

imkumawat avatar Sep 26 '22 17:09 imkumawat

Hi @bmccann36, this issue has been fixed by the following PR.

Thanks!

yenfryherrerafeliz avatar Sep 27 '22 14:09 yenfryherrerafeliz

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

github-actions[bot] avatar Oct 12 '22 00:10 github-actions[bot]