Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Uncaught (in promise) AbortException when running the unit-tests #12144

Merged

Conversation

Snuffleupagus
Copy link
Collaborator

These errors can/will occur if data is still loading when the document is destroyed, which is the case in the API unit-tests that load the tracemonkey.pdf file.
While this patch prevents these kind of problems, and thus allows us to update Jasmine again, I cannot help but thinking that it's slightly "hacky". Basically, we'll simply catch and ignore (some) rejected promises once the document is destroyed and/or its data loading is aborted. However, I don't think that these changes should cause issues in general, since we don't really care about errors once document destruction has started (note e.g. the fair number of catch handlers ignoring AbortExceptions already).

@Snuffleupagus
Copy link
Collaborator Author

/botio unittest

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/86238e08d994ec6/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.215.176.217:8877/431e719b47e6bda/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/86238e08d994ec6/output.txt

Total script time: 3.74 mins

  • Unit Tests: FAILED

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/431e719b47e6bda/output.txt

Total script time: 4.92 mins

  • Unit Tests: Passed

Comment on lines +2138 to +2143
sink.ready.catch(readyReason => {
if (this.destroyed) {
return; // Ignore any pending requests if the worker was terminated.
}
throw readyReason;
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compared to the fullReader case above, I wasn't actually able to trigger this code-path in any of the unit-tests. However, given the (fairly) small amount of code, the fact that this is consistent with the above, and to prevent any future issues I figured that this cannot hurt.

Given the (relatively) small size of a range request, as compared to the full request, triggering this is probably a lot more difficult and timing-dependent. E.g. it may still happen for a slow connection and/or a large rangeChunkSize option.

Comment on lines +425 to +430
return capability.promise.catch(reason => {
if (this.aborted) {
return; // Ignoring any pending requests after abort.
}
throw reason;
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes weren't necessary to get the unit-tests to run as-is with an updated Jasmine version, however with disableStream = true set they still failed with Uncaught (in promise) AbortException which thus necessitated these changes.

Given that we're already ignoring read data, in sendRequest, this is to some extent thus "consistent" behaviour.

@Snuffleupagus
Copy link
Collaborator Author

/botio test

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/8176f2c172adc23/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.215.176.217:8877/277d512d129a4a2/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/8176f2c172adc23/output.txt

Total script time: 26.73 mins

  • Font tests: Passed
  • Unit tests: FAILED
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/8176f2c172adc23/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/277d512d129a4a2/output.txt

Total script time: 29.54 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.215.176.217:8877/277d512d129a4a2/reftest-analyzer.html#web=eq.log

@Snuffleupagus
Copy link
Collaborator Author

Unfortunately there's apparently one remaining unit-test failure, which is limited to Google Chrome on the Linux bot:

TEST-UNEXPECTED-FAIL | creates pdf doc from non-existent URL | in chrome | Unhandled promise rejection: MissingPDFException: Missing PDF "http://127.0.0.1:34548/test/pdfs/non-existent.pdf". 

Perhaps unsurprisingly, I cannot reproduce this locally in Chrome on Windows since gulp unittest passes without issues. Could we still possibly proceed with this patch as-is, given that it improves things overall[1], since I'm not sure when (or even if) I'll be able to fix the remaining failure?


[1] Unfortunately, even the patch as-is took me hours of debugging/testing, spread out over a couple of days, to arrive at.

@timvandermeij
Copy link
Contributor

Could we still possibly proceed with this patch [...]

I would say that these changes make sense if the Jasmine update itself is left out of this PR until the last failure is fixed.

…tests

These errors can/will occur if data is still loading when the document is destroyed, which is the case in the API unit-tests that load the `tracemonkey.pdf` file.
While this patch prevents these kind of problems, and thus allows us to update Jasmine again, I cannot help but thinking that it's slightly "hacky". Basically, we'll simply catch and ignore (some) rejected promises once the document is destroyed and/or its data loading is aborted. However, I don't *think* that these changes should cause issues in general, since we don't really care about errors once document destruction has started (note e.g. the fair number of `catch` handlers ignoring `AbortException`s already).
@Snuffleupagus Snuffleupagus force-pushed the uncaught-promise-AbortException branch from 0ce25d9 to 6d192f9 Compare July 31, 2020 21:29
@Snuffleupagus
Copy link
Collaborator Author

I would say that these changes make sense if the Jasmine update itself is left out of this PR until the last failure is fixed.

Done; although I do find it to be quite unfortunate having to do so, since I worry that we'll "never" actually get the final test-failure fixed and thus be stuck at an old Jasmine-version indefinitely. (See e.g. issue #11996 which tracks another, fairly old, dependency problem that may sooner of later become a real problem.)

/botio unittest

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.215.176.217:8877/93ce393d3fb967f/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_unittest from @Snuffleupagus received. Current queue size: 0

Live output at: http://54.67.70.0:8877/8ab0e4e1a5c7388/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/8ab0e4e1a5c7388/output.txt

Total script time: 3.90 mins

  • Unit Tests: Passed

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/93ce393d3fb967f/output.txt

Total script time: 4.96 mins

  • Unit Tests: Passed

@timvandermeij
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.215.176.217:8877/a07cc93e5c5224f/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Received

Command cmd_test from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/46c1c9184bc186a/output.txt

@pdfjsbot
Copy link

From: Bot.io (Linux m4)


Failed

Full output at http://54.67.70.0:8877/46c1c9184bc186a/output.txt

Total script time: 26.85 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.67.70.0:8877/46c1c9184bc186a/reftest-analyzer.html#web=eq.log

@pdfjsbot
Copy link

From: Bot.io (Windows)


Failed

Full output at http://54.215.176.217:8877/a07cc93e5c5224f/output.txt

Total script time: 29.68 mins

  • Font tests: Passed
  • Unit tests: Passed
  • Regression tests: FAILED

Image differences available at: http://54.215.176.217:8877/a07cc93e5c5224f/reftest-analyzer.html#web=eq.log

@timvandermeij timvandermeij merged commit 0d20a2b into mozilla:master Jul 31, 2020
@timvandermeij
Copy link
Contributor

Looks good to me; another step closer to updating Jasmine in the end.

@Snuffleupagus Snuffleupagus deleted the uncaught-promise-AbortException branch August 1, 2020 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants