Angular dev server fails with ERR_STREAM_WRITE_AFTER_END

Discussão em 'Angular' iniciado por Irdis, Abril 4, 2025.

  1. Irdis

    Irdis Guest

    When I start angular server, it works okay and I'm able to browse angular application. Dev server proxies requests to underlying apps through proxy.conf.js. I cannot share proxy.conf.js, it basically returns url or reads some static content via fs.createReadStream('...').pipe(resp)

    "executor": "@angular-devkit/build-angular:dev-server",
    "options": {
    "buildTarget": "myapp:build:localLibs",
    "proxyConfig": "./apps/myapp/proxy.conf.js",
    "port": 4200,
    "servePath": "/"
    },


    But after several refreshes it server crashes with ERR_STREAM_WRITE_AFTER_END. The error is

    node:events:485
    throw er; // Unhandled 'error' event
    ^
    Error [ERR_STREAM_WRITE_AFTER_END]: write after end
    at write_ (node:_http_outgoing:955:11)
    at ServerResponse.write (node:_http_outgoing:904:15)
    at ReadStream.ondata (node:internal/streams/readable:1007:22)
    at ReadStream.emit (node:events:507:28)
    at addChunk (node:internal/streams/readable:559:12)
    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
    at Readable.push (node:internal/streams/readable:390:5)
    at node:internal/fs/streams:289:14
    at FSReqCallback.wrapper [as oncomplete] (node:fs:673:5)
    Emitted 'error' event on ServerResponse instance at:
    at ServerResponse.onerror (node:internal/streams/readable:1026:14)
    at ServerResponse.emit (node:events:519:35)
    at emitErrorNt (node:_http_outgoing:927:9)
    at process.processTicksAndRejections (node:internal/process/task_queues:91:21) {
    code: 'ERR_STREAM_WRITE_AFTER_END'
    }
    Node.js v23.11.0

    ———————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

    NX Running target serve for project myapp failed

    Failed tasks:

    - myapp:serve:development



    As you can see there is no user code in stack trace. I have no idea how to diagnose this problem. Any help is appreciated.

    Continue reading...

Compartilhe esta Página