verdaccio / monorepo

🏰 Core dependencies and plugins for verdaccio 5.x branch ⚠️ DEPRECATED
https://verdaccio.org
MIT License
81 stars 62 forks source link

aws-s3-storage-verdaccio: TypeError: argument #1 unsupported type undefined #695

Closed pedrow-coelho closed 6 months ago

pedrow-coelho commented 8 months ago

Describe the bug I have a problem with my aws-s3-storage-verdaccio plugin. Look at the log of my container which is in k8s.

http-errors deprecated non-error status code; use only 4xx or 5xx status codes at ../../usr/local/lib/node_modules/verdaccio-aws-s3-storage/node_modules/@verdaccio/commons-api/lib/index.js:113:45
error--- unexpected error: Connection timed out after 120000ms
Error: Connection timed out after 120000ms
    at Request.emit (/usr/local/lib/node_modules/verdaccio-aws-s3-storage/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/usr/local/lib/node_modules/verdaccio-aws-s3-storage/node_modules/aws-sdk/lib/request.js:686:14)
http <-- 500, user: myemail@gmail.com (172.70.175.81 via 10.41.153.216), req: 'GET /libphonenumber-js/-/libphonenumber-js-1.10.37.tgz', error: internal server error
error--- s3: [S3PackageManager readTarball readTarballStream event] error Connection timed out after 120000ms
fatal--- uncaught exception, please report this
TypeError: argument #1 unsupported type undefined
    at createError (/usr/local/lib/node_modules/verdaccio-aws-s3-storage/node_modules/http-errors/index.js:68:13)
    at getError (/usr/local/lib/node_modules/verdaccio-aws-s3-storage/node_modules/@verdaccio/commons-api/lib/index.js:113:45)
    at getCode (/usr/local/lib/node_modules/verdaccio-aws-s3-storage/node_modules/@verdaccio/commons-api/lib/index.js:151:10)
    at convertS3Error (/usr/local/lib/node_modules/verdaccio-aws-s3-storage/lib/s3Errors.js:43:38)
    at PassThrough.<anonymous> (/usr/local/lib/node_modules/verdaccio-aws-s3-storage/lib/s3PackageManager.js:398:50)

I have already updated to the version that fixes this problem but it continues to happen... could anyone help me? Verdaccio version: 5.28.0 Plugin version: 10.3.2

image

jeremydiazmeta commented 8 months ago

I am also experiencing the same issue. I am unable to download any packages. I get the following error:

TypeError: argument #1 unsupported type undefined
    at createError (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/node_modules/@verdaccio/commons-api/node_modules/http-e
rrors/index.js:68:13)
    at getError (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/node_modules/@verdaccio/commons-api/lib/index.js:113:45)
    at getCode (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/node_modules/@verdaccio/commons-api/lib/index.js:151:10)
    at convertS3Error (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/lib/s3Errors.js:43:38)
    at PassThrough.<anonymous> (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/lib/s3PackageManager.js:398:50)
    at PassThrough.emit (node:events:514:28)
    at PassThrough.emit (node:domain:488:12)
    at Request.<anonymous> (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/node_modules/aws-sdk/lib/request.js:590:14)
    at Request.callListeners (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/node_modules/aws-sdk/lib/sequential_executor.
js:106:20)
    at Request.emit (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/node_modules/aws-sdk/lib/request.js:686:14)
    at Request.transition (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/node_modules/aws-sdk/lib/state_machine.j
s:14:12)
    at /usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/usr/local/lib/node_modules/verdaccio/node_modules/verdaccio-aws-s3-storage/node_modules/aws-sdk/lib/request.js:688:12)

This is with verdaccio v5.29.0, verdaccio-storage-proxy v0.0.11, and verdaccio-aws-s3-storage v10.3.2

barrywoolgar commented 6 months ago

I have also run into this problem just now with the same versions.

I'm still investigating whether I've made a mistake with the S3 configuration (given we pass through s3Errors.js), but it looks like there's a problem here with how error messages from S3 are getting processed for display.

Thanks

barrywoolgar commented 6 months ago

OK, so the reported bug occurs if the AWS SDK returns an error with an undefined statusCode (ie. before an HTTP request) which the plugin's error handling code chokes on.

In my case, the real problem was my config credentials used accessKeyID instead of accessKeyId, thanks to a typo in the plugin documentation. You can workaround this by setting the AWS SDK default env vars of AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY to appropriate values and it'll just work.