tomve
(Tom)
2023 年 11 月 17 日午後 4:31
1
しばらく前に、ajax を介してコントローラーメソッドを呼び出し、その結果を返す Discourse プラグインを作成しました。この特定のリクエストは数分かかることがあり、以前は問題なく動作していました。
しかし、しばらくぶりに現在の Discourse バージョンでプラグインを試したところ、1 分後にリクエストが中止される問題が発生しています。
コードは次のようになります。
ajax("/my-plugin/import", {
type: "POST",
data: {
categoryId: this.categoryId,
otherData: ...
}
}).then((result) => { ... });
1 分後に表示されるエラーメッセージは次のとおりです。
Discourse Ember CLI Proxy Error
FetchError: http://127.0.0.1:3000/my-plugin/import へのリクエストは失敗しました。理由: 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)
この動作が過去 1 年間でどのように変化したのか、そしてタイムアウト設定を変更するオプションがあるのかを理解しようとしています。
david
(David Taylor)
2023 年 11 月 17 日午後 4:51
2
ここ最近の変更はないと思います。Discourse のバックエンドは、開発環境では 60 秒、本番環境では 30 秒後にリクエストをタイムアウトするように設定されています。
if ENV["RAILS_ENV"] != "production"
logger Logger.new(STDOUT)
# we want a longer timeout in dev cause first request can be really slow
timeout (ENV["UNICORN_TIMEOUT"] && ENV["UNICORN_TIMEOUT"].to_i || 60)
else
# By default, the Unicorn logger will write to stderr.
# Additionally, some applications/frameworks log to stderr or stdout,
# so prevent them from going to /dev/null when daemonized here:
stderr_path "#{discourse_path}/log/unicorn.stderr.log"
stdout_path "#{discourse_path}/log/unicorn.stdout.log"
# nuke workers after 30 seconds instead of 60 seconds (the default)
timeout 30
end
これは UNICORN_TIMEOUT 環境変数で開発環境で設定可能のようですが、本番環境では 30 秒にハードコードされています。
「いいね!」 2
pfaffman
(Jay Pfaffman)
2023 年 11 月 17 日午後 11:49
3
インポートを処理するためにジョブをスケジュールしたいのかもしれません。
「いいね!」 3
tomve
(Tom)
2023 年 11 月 30 日午後 12:46
4
結局、インポートをスケジュールジョブで処理するように書き直しました。これは、はるかに良い結果となりました。
「いいね!」 2
system
(system)
クローズされました:
2023 年 12 月 30 日午後 12:47
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.