Hi, I’ve recently converted my express app to netlify functions. I am running the code locally and have not yet built or deployed.
I set up a test route, /hello, which spits out some json. When making a request, I’m able to get the correct response from the server, but this error appears in the console and the server is terminated.
Does anyone know what could be causing this? Thanks.
Error:
Error: Received packet in the wrong sequence.
at p._parsePacket (Q:\React Apps\Pulse API\pulse-api\functions\app.js:325:93008)
at p._parsePacket (Q:\React Apps\Pulse API\pulse-api\functions\app.js:325:101737)
at p.write (Q:\React Apps\Pulse API\pulse-api\functions\app.js:325:95965)
at p.write (Q:\React Apps\Pulse API\pulse-api\functions\app.js:325:89476)
at Socket. (Q:\React Apps\Pulse API\pulse-api\functions\app.js:71:2421)
at Socket. (Q:\React Apps\Pulse API\pulse-api\functions\app.js:71:1523)
at Socket.emit (events.js:315:20)
at addChunk (_stream_readable.js:309:12)
at readableAddChunk (_stream_readable.js:284:9)
at Socket.Readable.push (_stream_readable.js:223:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
--------------------
at p._enqueue (Q:\React Apps\Pulse API\pulse-api\functions\app.js:325:90854)
at p.handshake (Q:\React Apps\Pulse API\pulse-api\functions\app.js:325:89599)
at _.connect (Q:\React Apps\Pulse API\pulse-api\functions\app.js:71:3293)
at Object. (Q:\React Apps\Pulse API\pulse-api\functions\app.js:325:28905)
at n (Q:\React Apps\Pulse API\pulse-api\functions\app.js:1:158)
at Object. (Q:\React Apps\Pulse API\pulse-api\functions\app.js:325:27328)
at n (Q:\React Apps\Pulse API\pulse-api\functions\app.js:1:158)
at Object. (Q:\React Apps\Pulse API\pulse-api\functions\app.js:154:56763)
at n (Q:\React Apps\Pulse API\pulse-api\functions\app.js:1:158)
at Q:\React Apps\Pulse API\pulse-api\functions\app.js:1:957
at Object. (Q:\React Apps\Pulse API\pulse-api\functions\app.js:1:967)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19) {
code: ‘PROTOCOL_INCORRECT_PACKET_SEQUENCE’,
fatal: true
}
Hi @EthanCrabb ,
This might be related:
opened 01:30PM - 19 Aug 20 UTC
closed 08:15AM - 20 Aug 20 UTC
type: bug
**Describe the bug**
I am using netlify functions using serverless-http to tr… anslate the express router routes to netlify functions and netlify-lambda for serving it locally. The server runs okay and the first api hit is a success. I get back a response but after this I get a connect ECONNREFUSED error and the server stops.
**To Reproduce**
Steps to reproduce the behavior:
1. Run `git clone https://github.com/usmanabdurrehman/socialserver.git`
2. Navigate to the cloned repository
3. Run `netlify-lambda`
4. See that the CLI exits with an error
**Configuration**
**netlify.toml config:**
```toml
[build]
functions = "functions"
```
**System config:**
```
OS: Windows 7 6.1.7601
CPU: (4) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
Memory: 905.19 MB / 3.90 GB
Binaries:
Node: 10.15.3 - C:\Program Files\nodejs\node.EXE
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
```
**CLI Output**
```
Request from ::1: GET /.netlify/functions/api/hmn
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
(node:7464) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Your lambda function didn't return a body, which may be a mistake. Check our Usage docs for examples (https://github.com/netlify/netlify-lambda#usage).
If this is intentional, you can silence this warning by setting process.env.SILENCE_EMPTY_LAMBDA_WARNING to a truthy value or process.env.CONTEXT to 'production'
Response with status 304 in 629 ms.
C:\Users\Spinnin\desktop\socialserver2\functions\api.js:50
*/e.exports=function(e,a){if(!1!==t(e))return o(a,null,e),e;return function(e,a){var n=e.__onFinished;n&&n.queue||(n=e.__onFinished=function(e){function a(n){if(e.__onFinished===a&&(e.__onFinished=null),a.queue){var i=a.queue;a.queue=null;for(var o=0;o<i.length;o++)i[o](n,e)}}return a.queue=[],a}(e),function(e,a){var n,o,t=!1;function r(e){n.cancel(),o.cancel(),t=!0,a(e)}function s(a){e.removeListener("socket",s),t||n===o&&(o=i([[a,"error","close"]],r))}if(n=o=i([[e,"end","finish"]],r),e.socket)return void s(e.socket);e.on("socket",s),void 0===e.socket&&function(e,a){var n=e.assignSocket;if("function"!=typeof n)return;e.assignSocket=function(e){n.call(this,e),a(e)}}(e,s)}(e,n));n.queue.push(a)}(e,a),e},e.exports.isFinished=t;var i=n(150),o="function"==typeof setImmediate?setImmediate:function(e){process.nextTick(e.bind.apply(e,arguments))};function t(e){var a=e.socket;return"boolean"==typeof e.finished?Boolean(e.finished||a&&!a.writable):"boolean"=
Error: connect ECONNREFUSED 127.0.0.1:3306
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1097:14)
--------------------
at u._enqueue (C:\Users\Spinnin\desktop\socialserver2\functions\api.js:389:67404)
at u.handshake (C:\Users\Spinnin\desktop\socialserver2\functions\api.js:389:66149)
at d.connect (C:\Users\Spinnin\desktop\socialserver2\functions\api.js:78:6497)
at Object.<anonymous> (C:\Users\Spinnin\desktop\socialserver2\functions\api.js:50:1180)
at n (C:\Users\Spinnin\desktop\socialserver2\functions\api.js:1:220)
at Object.<anonymous> (C:\Users\Spinnin\desktop\socialserver2\functions\api.js:78:1075)
at n (C:\Users\Spinnin\desktop\socialserver2\functions\api.js:1:220)
at Object.<anonymous> (C:\Users\Spinnin\desktop\socialserver2\functions\api.js:205:89180)
at Object.<anonymous> (C:\Users\Spinnin\desktop\socialserver2\functions\api.js:205:89788)
at n (C:\Users\Spinnin\desktop\socialserver2\functions\api.js:1:220)
at C:\Users\Spinnin\desktop\socialserver2\functions\api.js:1:1019
at Object.<anonymous> (C:\Users\Spinnin\desktop\socialserver2\functions\api.js:1:1030)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! socialServer2@1.0.0 start: `netlify-lambda serve src`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the socialServer2@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Spinnin\AppData\Roaming\npm-cache\_logs\2020-08-19T13_28_42_699Z-debug.log
**error log**
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm@6.4.1
3 info using node@v10.15.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle socialServer2@1.0.0~prestart: socialServer2@1.0.0
6 info lifecycle socialServer2@1.0.0~start: socialServer2@1.0.0
7 verbose lifecycle socialServer2@1.0.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle socialServer2@1.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Spinnin\desktop\socialserver2\node_modules\.bin;C:\Users\Spinnin\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Spinnin\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files\nodejs;C:\PHP;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\PROGRA~2\ThriXXX\3D SexVilla;C:\PROGRA~2\PICC;C:\Program Files (x86)\Smart Projects\IsoBuster;C:\Users\Spinnin\AppData\Roaming\Sublime Text 3\Packages\User;C:\Users\Spinnin\AppData\Local\Programs\Python\Python35\Scripts;C:\Users\Spinnin\AppData\Local\Programs\Python\Python35;C:\Modeltech_5.7g\win32;C:\Python34\Scripts;C:\Program Files\heroku\bin;C:\flutter\flutter\bin;C:\Users\Spinnin\AppData\Roaming\npm;C:\MinGW\bin;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
9 verbose lifecycle socialServer2@1.0.0~start: CWD: C:\Users\Spinnin\desktop\socialserver2
10 silly lifecycle socialServer2@1.0.0~start: Args: [ '/d /s /c', 'netlify-lambda serve src' ]
11 silly lifecycle socialServer2@1.0.0~start: Returned: code: 1 signal: null
12 info lifecycle socialServer2@1.0.0~start: Failed to exec start script
13 verbose stack Error: socialServer2@1.0.0 start: `netlify-lambda serve src`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:189:13)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:189:13)
13 verbose stack at maybeClose (internal/child_process.js:970:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid socialServer2@1.0.0
15 verbose cwd C:\Users\Spinnin\desktop\socialserver2
16 verbose Windows_NT 6.1.7601
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v10.15.3
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error socialServer2@1.0.0 start: `netlify-lambda serve src`
22 error Exit status 1
23 error Failed at the socialServer2@1.0.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
```
If not, it would help us if you could share a repo so we could test.
1 Like
This works! But what changes do I need to make to my deploy settings? eg: build command
Hi @EthanCrabb ,
If you say it works, doesn’t it mean you got it working? What exactly do you mean when you say you need to change deploy settings?
It can help if you share your repo.
I figured it out myself, I just removed the build command and deployed as is. Thanks for your help, greatly appreciated.