Cannot read property 'jqXHR' of undefined

I just did a minor change in the privacy policy but when I submitted the edit, it would not complete saving (the saving wheel kept spinning and spinning). While I was waiting, I went to the TOS (in a new browser tab) to do a change there too. After saving that edit without problems, I went back to the privacy policy, but the wheel was still spinning. So I went ahead and tried to edit the post again (in the same browser tab). Ironically, I found that the change was already made but I wasn’t sure whether it was really saved or whether I was just looking at the same unsaved editor content. So I clicked save to make sure it is saved. That’s when this error popped up.

Can you repro this @techapj?

I am unable to repro this error on latest Discourse version.

For what it’s worth, I just had this same issue with a recent Discourse version (commit c10941b, basically the stable branch from 2019-02-17, not a release).

I was able to reproduce it a few times, but then not anymore, and it’s the first time ever that I had this issue. So very much an edge case …

What happened:

  1. I did a major update to a complex wiki post (which is a Discourse manual we wrote for our purposes).

  2. As experienced by the OP, Discourse would not complete saving (the saving wheel kept spinning and spinning). I eventually cancelled the process.

  3. I tried to make the very same edit again, and this error popped up:

    TypeError: Cannot read property ‘jqXHR’ of undefined

    That was reproducible for several further attempts to make the same edit in this post.

  4. I tried to make an edit to a different post, and that went without problems. I tried to post the same edit that failed for the manual wiki as edit to the different post, and that worked without problems, too (so it does not seem to be connected to the posted content).

  5. I tried a small (few words) edit to the manual wiki where the original edit failed. That worked, but it took a long time (about two minutes).

  6. I tried the failed edit again on the manual wiki, and this time it worked. And all subsequent edits worked, too.

I found the following error log entries for the time and post where this issue happened:

(Edit: upon further inspection, that error in the logs seems rather unrelated as the log shows it also in multiple other cases, which did not involve the “TypeError: Cannot read property ‘jqXHR’ of undefined” error message on the client side. But I saved the JS file where the error happened, if somebody wants to look at it.)

Message (5 copies reported)
Uncaught Error: Not Found
Url: https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js
Line: 14
Column: 25883
Window Location: https://edgeryders.eu/t/discourse-user-manual-for-edgeryders-eu/6463/1
Backtrace
Error: Not Found
    at s (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:14:26084)
    at o (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:14:25941)
    at i (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:14:25836)
    at Object.trigger (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:17:26248)
    at https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:17:28250
    at e.invoke (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:3979)
    at e.flush (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:2902)
    at e.flush (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:4992)
    at e._end (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:9818)
    at e.end (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:6320)
    at e._run (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:10333)
    at e.run (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:9:6965)
    at a (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:4:29639)
    at Object.r.error (https://edgeryders.eu/assets/application-b7e1701c68247f1198a83883a70ad5264302ef5fd43e37b09ce6d0125baa133a.js:7:26015)
    at u (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:2:6854)
    at Object.fireWith [as rejectWith] (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:2:7603)
    at n (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:3:10363)
    at XMLHttpRequest.<anonymous> (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06ed7d3.js:3:15221)

Env
    hostname	server.edgeryders.eu
    process_id	27682
    application_version	2.2.1
    HTTP_HOST	edgeryders.eu
    REQUEST_URI	/logs/report_js_error
    REQUEST_METHOD	POST
    HTTP_USER_AGENT	Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/73.0.3683.75 Chrome/73.0.3683.75 Safari/537.36
    HTTP_ACCEPT	*/*
    HTTP_REFERER	https://edgeryders.eu/t/discourse-user-manual-for-edgeryders-eu/6463/1
    params
        message	Uncaught Error: Not Found Url: https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb3736
        url	https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58a4a8a83bcee2d99174547b01c06
        line	14
        column	25883
        window_location	https://edgeryders.eu/t/discourse-user-manual-for-edgeryders-eu/6463/1
        stacktrace	Error: Not Found at s (https://edgeryders.eu/assets/ember_jquery-cf9339810550f9c92505dfbb37362c58

Sorry @tanius Akismet thought your post was spam for some reason and deleted it, I just went ahead and undeleted it.

@techAPJ can you re-test given this info?

この問題は続いていますか?

"jqXHR フィールドが読み取れません"というエラーは、失敗した AJAX 呼び出しを囲む当社のカスタムエラーハンドリングコードから発生しています。

いいえ、持続していません…過去1年はエラーを目にしていません。ただし、そもそもこれは極めて稀なケースであり、明確に再現できるものでもなかったので、現時点で「欠如の証明」としては受け取らないでください…

余談ですが、投稿保存の失敗に関連して改善できるもう一つの部分があります。具体的には、ネットワークエラーにより投稿や投稿編集の保存が失敗した場合、システムがそれを通知するまでに非常に長い時間がかかります。このリクエストを再送信する方法が不足しています。「キャンセル」ボタンでは役に立ちません。なぜなら、それでは投稿や投稿編集の内容を失ってしまうからです。

再現手順がないと何もできません。Chrome のネットワークタブで、あえて不安定なネットワークに切り替えてみましたか?それなら再現できるかもしれません。

このエラーは、以下の作業中に発生しました。
すべてプラグイン内で実行しています。

Post クラスにバリデーターを追加しました。中身は重要ではありませんが、返信のために記載します。

frozen_string_literal: true

class MainPostValidator < ActiveModel::Validator
def validate(record)
puts ‘TTTTT’
p record

raw = record.raw

unless raw.present?
  post.errors.add :base, 'This record is invalid'
end

end

private
def some_complex_logic
# …
end
end

新しい変更でサーバーを再起動する前に、投稿の編集画面を開いており、保存変更がバリデーターをトリガーするか確認する準備をしていました。

サーバーを再起動しましたが、ページはリフレッシュしませんでした!投稿の「変更を保存」をタップすると、そのエラーが表示されました。ページをリフレッシュするとエラーは消え、もしかするとサーバーインスタンスの再起動も関係していたかもしれません。

これはすべてローカル開発環境でのことです。

参考になれば幸いです :slight_smile:

バリデーターは新しいファイルで宣言され、バリデーターを適用するための Post の追加コードも別のファイルにありました。

require_dependency 'post' Post.class_eval { include ActiveModel::Validations validates_with MainPostValidator }