metarhia/impress

Not consistent response on exceeded global timeout of API endpoint and webhook execution

KLarpen opened this issue · 1 comments

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

  1. 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
  2. Check that general timeouts config at application/config/server.js contains request: 5000
  3. Put file application/api/example/testTimeout.js
({
  access: 'public',
  async method() {
    await node.timers.promises.setTimeout(6000);
    return { returned: true };
  },
});
  1. Run server
  2. Open browser tab with DevTools (console & network tabs in it)
  3. Check that WS request api is active and there is messages
  4. Type in console await api.example.testTimeout(); and run
  5. 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}}
  1. Open another browser tab and query http://localhost:8001/api/example/testTimeout
  2. You will receive message {"type":"callback","id":0,"error":{"message":"Timeout of 5000ms reached","code":408}} with response HTTP header Status code: 408 Request Timeout
  3. Extend webhooks router in application/api/hook.1.js with line await node.timers.promises.setTimeout(6000);
  4. In a browser tab query http://localhost:8001/api/hook/something
  5. You will receive message {"type":"callback","id":0,"error":{"message":"Internal Server Error","code":500}} with response HTTP header Status 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.

It might be related to metarhia/metacom#485