Not consistent response on exceeded global timeout of API endpoint and webhook execution
KLarpen opened this issue · 1 comments
KLarpen commented
Impress and Node.js versions
Impress: 3.0.13+(latest change), Metautil ^3.15.0, Node: 20.9.0
Platform
macOS 14.1.2 Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000 arm64
Describe the bug
API endpoints responses on exceeded global timeout:
- WS transport
{message: "Timeout of 5000ms reached", code: 408}
- HTTP transport
{message: "Timeout of 5000ms reached", code: 408}
with status code "408 Request Timeout" - webhook endpoint
{"message":"Internal Server Error","code":500}
with status code 500
However server's log for webhook request contains
GET /api/hook/something 500 Error: Timeout of 5000ms reached
To Reproduce
- Start with Example project but in case the Impress version still 3.0.13 you need to manually apply 2 lines of fix into
node_modules/impress/lib/procedure.js
from e49c066 - Check that general
timeouts
config atapplication/config/server.js
containsrequest: 5000
- Put file
application/api/example/testTimeout.js
({
access: 'public',
async method() {
await node.timers.promises.setTimeout(6000);
return { returned: true };
},
});
- Run server
- Open browser tab with DevTools (console & network tabs in it)
- Check that WS request
api
is active and there is messages - Type in console
await api.example.testTimeout();
and run - You will receive exceeded timeout message
{"type":"call","id":6,"method":"example/testTimeout","args":{}}
{"type":"callback","id":6,"error":{"message":"Timeout of 5000ms reached","code":408}}
- Open another browser tab and query http://localhost:8001/api/example/testTimeout
- You will receive message
{"type":"callback","id":0,"error":{"message":"Timeout of 5000ms reached","code":408}}
with response HTTP headerStatus code: 408 Request Timeout
- Extend webhooks
router
inapplication/api/hook.1.js
with lineawait node.timers.promises.setTimeout(6000);
- In a browser tab query http://localhost:8001/api/hook/something
- You will receive message
{"type":"callback","id":0,"error":{"message":"Internal Server Error","code":500}}
with response HTTP headerStatus code: 500 Internal Server Error
Expected behavior
It better to ask multiple impress users: is that a bug and what behavior actually expected by them. May you help please, @nechaido @tshemsedinov ? At least to tag multiple known users of Impress for collective decision.
Screenshots
No response
Additional context
Question origin #1949 (comment) , so it relate to the future release of Impress.
KLarpen commented
It might be related to metarhia/metacom#485