A while I ago I created a Discourse plugin which calls a controller method via ajax and then returns the result. This particular request can run for a few minutes, and this was running fine.
But now after a long while I tried the plugin in the current Discourse version and I’m running into an issue where the request is aborted after 1 minute.
FetchError: request to http://127.0.0.1:3000/my-plugin/import failed, reason: socket hang up
at ClientRequest. (file:///src/app/assets/javascripts/node_modules/node-fetch/src/index.js:108:11)
at ClientRequest.emit (node:events:526:35)
at Socket.socketOnEnd (node:_http_client:525:9)
at Socket.emit (node:events:526:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
What I’m trying to understand is why this behaviour might have changed in the past year? And if there is any option to change the timeout setting.
I don’t think there has been any recent change here. Discourse’s backend is configured to timeout requests after 60 seconds in development, or 30 seconds in production
It looks like this is configurable in development via the UNICORN_TIMEOUT env variable. But production is hard-coded to 30 seconds.