agutoli / serverless-layers

Serverless.js plugin implementing AWS Lambda Layers, reducing lambda size, warm-up, and deployment time.
MIT License
229 stars 54 forks source link

TypeError: Cannot read properties of undefined (reading 'pipes') #80

Open andreyvital opened 2 years ago

andreyvital commented 2 years ago

Hey—I'm getting the following error:

  TypeError: Cannot read properties of undefined (reading 'pipes')
      at ReadStream.Readable.pipe (node:internal/streams/readable:658:13)
      at Readable.<anonymous> (/Users/(...)/Projects/(...)/api/node_modules/lazystream/lib/lazystream.js:33:12)
      at Readable.instance.<computed> (/Users/(...)/Projects/(...)/api/node_modules/lazystream/lib/lazystream.js:18:14)
      at Readable.read (/Users/(...)/Projects/(...)/api/node_modules/lazystream/node_modules/readable-stream/lib/_stream_readable.js:443:10)
      at resume_ (/Users/(...)/Projects/(...)/api/node_modules/lazystream/node_modules/readable-stream/lib/_stream_readable.js:790:12)
      at processTicksAndRejections (node:internal/process/task_queues:83:21)
      at runNextTicks (node:internal/process/task_queues:65:3)
      at processImmediate (node:internal/timers:437:9)

I've tried debugging what's the root cause, but no luck.

Versions:

api % cat node_modules/serverless-layers/node_modules/archiver/package.json |jq .version
"3.1.1"
api % cat node_modules/serverless-layers/package.json |jq .version
"2.5.1"
api % cat node_modules/serverless/package.json |jq .version
"2.67.0"

Settings (serverless.yml):

serverless-layers:
  packageManager: npm
  compileDir: .serverless
  forceInstall: ${env:SERVERLESS_LAYERS_FORCE_INSTALL, false}
  dependenciesPath: package.json
  compatibleRuntimes: ["nodejs"]
  layersDeploymentBucket: (...)
  # Why ../../..? Because the script runs on `.serverless/layers/nodejs`
  customInstallationCommand: "../../../scripts/build/install-node-modules.sh"

install-node-modules.sh

echo "Installing dependencies: $(pwd)"
npm install --loglevel=error --no-optional --only=production --audit=false
npm prune --production --audit=false

echo "Running https://github.com/tj/node-prune"
node-prune --exclude "*.d.ts" ./node_modules
la-jamesh commented 1 year ago

Any luck on this?

chuankaiwei commented 1 year ago

same issue. Any luck on this?

--- updates

In my case, It was the serverless-s3-sync issue. When I remove it, everything is OK.

greenlife-developer commented 1 year ago

Same Issue, has anyone solved it,

Mine worked in development, but gave the issue on production

2023-06-17T10:16:06.144530+00:00 app[web.1]: await stream.pipe(fs.createWriteStream(${req.body.phone}.pdf)); 2023-06-17T10:16:06.144530+00:00 app[web.1]: ^ 2023-06-17T10:16:06.144530+00:00 app[web.1]: 2023-06-17T10:16:06.144531+00:00 app[web.1]: TypeError: Cannot read properties of undefined (reading 'pipe')

That is on heroku log