Home
Support Forums

"Error: Socket hang up" on deployed function

Website: https://josephrex.me
Puppeteer-core version: 13.0.1
Chrome-aws-lambda version: 10.1.0

I have a PDF function with its code here on my GitHub . This runs fine in Netlify dev but throws socket hang up errors when deployed.

From searching, it appears people only encountered this in netlify dev (based on posts like this).

I tried addressing this like other users of aws lambda seem to have gone about it from this issue:

but it appears that the problem i from some linux packages missing and I’m unable to install them here on netlify.

I’ve seen people successfully deploy functions with puppeteer-core and chrome-aws-lambda at older versions so I tried using old versions but still had no luck.

Can I get any help on this. Is there some packages we can have ready on the lambda host that’ll make this work?

Here’s the full error log:

6:59:57 AM: e0be7c60 ERROR  ErrorEvent {
  [Symbol(kTarget)]: WebSocket {
    _events: [Object: null prototype] { open: [Function], error: [Function] },
    _eventsCount: 2,
    _maxListeners: undefined,
    _binaryType: 'nodebuffer',
    _closeCode: 1006,
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: <Buffer >,
    _closeTimer: null,
    _extensions: {},
    _protocol: '',
    _readyState: 3,
    _receiver: null,
    _sender: null,
    _socket: null,
    _bufferedAmount: 0,
    _isServer: false,
    _redirects: 0,
    _url: 'ws://127.0.0.1:46333/devtools/browser/667013d5-6445-402d-8032-279ebe822a92',
    _req: null,
    [Symbol(kCapture)]: false
  },
  [Symbol(kType)]: 'error',
  [Symbol(kError)]: Error: read ECONNRESET
      at TCP.onStreamRead (internal/stream_base_commons.js:209:20) {
    errno: -104,
    code: 'ECONNRESET',
    syscall: 'read'
  },
  [Symbol(kMessage)]: 'read ECONNRESET'
}
6:59:57 AM: e0be7c60 Duration: 3491.99 ms	Memory Usage: 443 MB	Init Duration: 222.11 ms	
7:18:21 AM: 22ea6328 ERROR  ErrorEvent {
  [Symbol(kTarget)]: WebSocket {
    _events: [Object: null prototype] { open: [Function], error: [Function] },
    _eventsCount: 2,
    _maxListeners: undefined,
    _binaryType: 'nodebuffer',
    _closeCode: 1006,
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: <Buffer >,
    _closeTimer: null,
    _extensions: {},
    _protocol: '',
    _readyState: 3,
    _receiver: null,
    _sender: null,
    _socket: null,
    _bufferedAmount: 0,
    _isServer: false,
    _redirects: 0,
    _url: 'ws://127.0.0.1:38825/devtools/browser/88733ab3-51a2-4102-9ac8-aacd68ff6af5',
    _req: null,
    [Symbol(kCapture)]: false
  },
  [Symbol(kType)]: 'error',
  [Symbol(kError)]: Error: socket hang up
      at connResetException (internal/errors.js:639:14)
      at Socket.socketOnEnd (_http_client.js:499:23)
      at Socket.emit (events.js:412:35)
      at endReadableNT (internal/streams/readable.js:1334:12)
      at processTicksAndRejections (internal/process/task_queues.js:82:21) {
    code: 'ECONNRESET'
  },
  [Symbol(kMessage)]: 'socket hang up'
}
7:18:21 AM: 22ea6328 Duration: 3466.87 ms	Memory Usage: 424 MB	Init Duration: 225.02 ms	
7:23:50 AM: 8619e724 ERROR  ErrorEvent {
  [Symbol(kTarget)]: WebSocket {
    _events: [Object: null prototype] { open: [Function], error: [Function] },
    _eventsCount: 2,
    _maxListeners: undefined,
    _binaryType: 'nodebuffer',
    _closeCode: 1006,
    _closeFrameReceived: false,
    _closeFrameSent: false,
    _closeMessage: <Buffer >,
    _closeTimer: null,
    _extensions: {},
    _protocol: '',
    _readyState: 3,
    _receiver: null,
    _sender: null,
    _socket: null,
    _bufferedAmount: 0,
    _isServer: false,
    _redirects: 0,
    _url: 'ws://127.0.0.1:41655/devtools/browser/4c1a9754-0dfd-4d4a-b59b-8312f34480ee',
    _req: null,
    [Symbol(kCapture)]: false
  },
  [Symbol(kType)]: 'error',
  [Symbol(kError)]: Error: socket hang up
      at connResetException (internal/errors.js:639:14)
      at Socket.socketOnEnd (_http_client.js:499:23)
      at Socket.emit (events.js:412:35)
      at endReadableNT (internal/streams/readable.js:1334:12)
      at processTicksAndRejections (internal/process/task_queues.js:82:21) {
    code: 'ECONNRESET'
  },
  [Symbol(kMessage)]: 'socket hang up'
}

Thank you

Hey @josephrexme,

While I don’t have a fix for this, it might be occuring due to the function going over Lambda’s limits.

Would it be possible for you to create a streamed-down reproduction of this issue so we can check it further? Your current repo has a lot in it, it seems, if we can get a repo only about this issue, we can probably pass it on to the engineers for further investigation if needed.

Hi @hrishikesh so I put it on a separate repo at GitHub - josephrexme/pdf-function and it works fine at https://pdf.josephrex.me/.netlify/functions/pdf . Thanks for the tip

1 Like