Skip to content

Browser session doesn't recover after edge function failure #5676

@josephmanso

Description

@josephmanso

Describe the bug

After an edge function crashes on page load, we aren't able to recover the browser session until closing the tab and reloading the page.

Steps to reproduce

Unfortunately, this is on a private repository so it cannot be shared.

  • Using the Netlify CLI
  • Using edge functions
  • Using the netlify dev command
  1. Booting up the server and loading the page in the browser with a working edge function - everything works as expected
  2. Server is turned off (ctrl + c)
  3. Throw an error inside the edge function, start up the server again. Edge function crashes the server (browser untouched) with the following error:
Error: read ECONNRESET
   at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
Emitted 'error' event on TLSSocket instance at:
   at TLSSocket.onerror (node:internal/streams/readable:785:14)
   at TLSSocket.emit (node:events:513:28)
   at TLSSocket.emit (node:domain:489:12)
   at emitErrorNT (node:internal/streams/destroy:151:8)
   at emitErrorCloseNT (node:internal/streams/destroy:116:3)
   at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
 errno: -54,
 code: 'ECONNRESET',
 syscall: 'read'
}
  1. Remove the offending line, reboot the server.
  2. Server continues to crash (although offending line is removed) with the following error:
TypeError: res.writeHead is not a function
    at ProxyServer.<anonymous> (file:///Users/josephmanso/Repos/asanadotcom/node_modules/netlify-cli/src/utils/proxy.mjs:362:9)
    at ProxyServer.emit (/Users/josephmanso/Repos/asanadotcom/node_modules/netlify-cli/node_modules/eventemitter3/index.js:204:33)
    at ClientRequest.onOutgoingError (/Users/josephmanso/Repos/asanadotcom/node_modules/netlify-cli/node_modules/http-proxy/lib/http-proxy/passes/ws-incoming.js:157:16)
    at ClientRequest.emit (node:events:513:28)
    at ClientRequest.emit (node:domain:489:12)
    at Socket.socketErrorListener (node:_http_client:502:9)
    at Socket.emit (node:events:513:28)
    at Socket.emit (node:domain:489:12)
    at emitErrorNT (node:internal/streams/destroy:151:8)
    at emitErrorCloseNT (node:internal/streams/destroy:116:3)
  1. Only when the browser is closed and re-opened, we can run the server again

Configuration

Can't share the entire toml file for security reasons, however can show the dev block:

[dev]
  command = "npm run start:node-server"
  targetPort = 4000
  port = 443
  autoLaunch = false
  [dev.https]
    certFile = "<some_string>"
    keyFile = "<some_string>"

Environment

System:
OS: macOS 13.3.1
CPU: (10) arm64 Apple M1 Max
Memory: 1.85 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.16.0 - ~/.nvm/versions/node/v18.16.0/bin/node
npm: 9.5.1 - ~/.nvm/versions/node/v18.16.0/bin/npm
npmPackages:
netlify-cli: ^14.1.0 => 14.2.1
npmGlobalPackages:
netlify-cli: 14.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions