Closed DDDDDanica closed 4 years ago
Sorry for the late reply. Your example should already work with stubby. Have you tried it?
Also, welcome to Github and submitting issues!
Hi! I'm with a problem related to OPTIONS method. Trying to respond to a similar request, I got the error:
events.js:163 throw er; // Unhandled 'error' event ^
Error: write after end at ServerResponse.write (_http_outgoing.js:485:15) at callback (/home/rafael/.nvm/versions/node/v7.9.0/lib/node_modules/stubby/src/portals/stubs.js:46:18) at Endpoints.found (/home/rafael/.nvm/versions/node/v7.9.0/lib/node_modules/stubby/src/models/endpoints.js:128:5) at Endpoints.find (/home/rafael/.nvm/versions/node/v7.9.0/lib/node_modules/stubby/src/models/endpoints.js:102:17) at IncomingMessage.
(/home/rafael/.nvm/versions/node/v7.9.0/lib/node_modules/stubby/src/portals/stubs.js:54:22) at emitNone (events.js:86:13) at IncomingMessage.emit (events.js:188:7) at endReadableNT (_stream_readable.js:975:12) at _combinedTickCallback (internal/process/next_tick.js:80:11) at process._tickCallback (internal/process/next_tick.js:104:9)
Then the stubby simply crashes. Apparently the response is ending early, before the body is written. How can I solve this?
It appears you are using a development version of node.js. Does the same thing occur on the latest stable 6.x version of node?
I am having the same issue.
I'm using 4.1.1 of Stubby with the LTS 10.x version of node and the following config:
- request:
method: [OPTIONS]
url: ^/(.*)$
response:
status: 200
The error is:
events.js:174 throw er; // Unhandled 'error' event ^
Error [ERR_STREAM_WRITE_AFTEREND]: write after end at write (_http_outgoing.js:572:17) at ServerResponse.write (_http_outgoing.js:567:10) at callback (/usr/local/lib/node_modules/stubby/src/portals/stubs.js:46:18) at Endpoints.found (/usr/local/lib/node_modules/stubby/src/models/endpoints.js:128:5) at Endpoints.find (/usr/local/lib/node_modules/stubby/src/models/endpoints.js:102:17) at IncomingMessage.
(/usr/local/lib/node_modules/stubby/src/portals/stubs.js:54:22) at IncomingMessage.emit (events.js:203:15) at endReadableNT (_stream_readable.js:1145:12) at process._tickCallback (internal/process/next_tick.js:63:19) Emitted 'error' event at: at writeAfterEndNT (_http_outgoing.js:634:7) at process._tickCallback (internal/process/next_tick.js:63:19)
I am having the same issue.
I'm using 4.1.1 of Stubby with the LTS 10.x version of node and the following config:
- request: method: [OPTIONS] url: ^/(.*)$ response: status: 200
The error is:
events.js:174 throw er; // Unhandled 'error' event ^ Error [ERR_STREAM_WRITE_AFTEREND]: write after end at write (_http_outgoing.js:572:17) at ServerResponse.write (_http_outgoing.js:567:10) at callback (/usr/local/lib/node_modules/stubby/src/portals/stubs.js:46:18) at Endpoints.found (/usr/local/lib/node_modules/stubby/src/models/endpoints.js:128:5) at Endpoints.find (/usr/local/lib/node_modules/stubby/src/models/endpoints.js:102:17) at IncomingMessage. (/usr/local/lib/node_modules/stubby/src/portals/stubs.js:54:22) at IncomingMessage.emit (events.js:203:15) at endReadableNT (_stream_readable.js:1145:12) at process._tickCallback (internal/process/next_tick.js:63:19) Emitted 'error' event at: at writeAfterEndNT (_http_outgoing.js:634:7) at process._tickCallback (internal/process/next_tick.js:63:19)
I'm having the same problem...
I had the same problem and I was reading the source code and I realized that we shouldn't create an endpoint for the Options method. If we look at this file:
https://github.com/mrak/stubby4node/blob/master/src/portals/portal.js
We can see that option method is handle automatically (even if we see a 404 in the console).
I am unable to reproduce this (node v12.18.0)
Closing as the original issue was being able to support OPTIONS requests which stubby should already support.
Something like this would be so handy :)