Local API endpoint queue settings doesn't work
KLarpen opened this issue · 0 comments
KLarpen commented
Impress and Node.js versions
Impress: 3.0.13 Node: 20.9.0, 18.18.2
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
Local settings of the queue, placed directly into API endpoint module, not working at all. Any values there just doesn't applied, so the queue restrictions on the endpoint doesn't applied as well.
To Reproduce
- Start with Example project
- Check that general queue config at
application/config/server.js
contains
Lines 15 to 19 in 4cabe81
- Put file
application/api/example/testQueue.js
({
access: 'public',
queue: {
concurrency: 1,
size: 1,
timeout: 1500,
},
async method() {
await node.timers.promises.setTimeout(2900);
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.testQueue();
and call it 3 times quickly (without awaiting for results) - All of request will return successfully after obvious concurrent execution despite our local queue setup.
{"type":"call","id":4,"method":"example/testQueue","args":{}}
{"type":"call","id":5,"method":"example/testQueue","args":{}}
{"type":"call","id":6,"method":"example/testQueue","args":{}}
{"type":"callback","id":4,"result":{"returned":true}}
{"type":"callback","id":5,"result":{"returned":true}}
{"type":"callback","id":6,"result":{"returned":true}}
Expected behavior
Local queue settings of the API endpoint must be applied to control behaviour. Reproducing example above we expect :
- first return from the last request due to full queue without possibility to add any more
- second return from the 2nd request due to reached timeout awaiting in the queue
- 3rd return from the 1st request with successfull result of the long running function.
Screenshots
No response
Additional context
I'm already investigating possible fix to make pull request.