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

Improve error message for non-existent local files #6608

Merged

Conversation

Rob--W
Copy link
Member

@Rob--W Rob--W commented Nov 8, 2015

I received multiple reports about the following cryptic error in the Chrome extension when the user tried to open a local file:

PDF.js v1.1.527 (build: 2096a2a)
Message: Cannot read property 'Symbol(Symbol.iterator)' of null

This error most likely originated from core/stream.js:

function Stream(arrayBuffer, start, length, dict) {
  this.bytes = (arrayBuffer instanceof Uint8Array ?
                arrayBuffer : new Uint8Array(arrayBuffer));
                                             ^^^^^^^^^^^

arrayBuffer is null, and that in turn is caused by the fact that for non-existing files, there is no data. I've applied two fixes:

  1. Never call onDone with a void buffer, but call the error handler
    instead.
  2. Show a sensible error message for local files with status = 0.

To get the error, simply install the Chrome extension, open any PDF file to get the extension URL, and then append some non-existent local file. E.g. chrome-extension://oemmndcbldboiebfnladdacbdfmadadm/file:///tmp/doesnotexist.pdf

I received multiple reports about the following cryptic error in the
Chrome extension when the user tried to open a local file:

> PDF.js v1.1.527 (build: 2096a2a)
> Message: Cannot read property 'Symbol(Symbol.iterator)' of null

This error most likely originated from core/stream.js:

    function Stream(arrayBuffer, start, length, dict) {
      this.bytes = (arrayBuffer instanceof Uint8Array ?
                    arrayBuffer : new Uint8Array(arrayBuffer));
                                                 ^^^^^^^^^^^
`arrayBuffer` is `null`, and that in turn is caused by the fact that
for non-existing files, there is no data. I've applied two fixes:

1. Never call onDone with a void buffer, but call the error handler
   instead.
2. Show a sensible error message for local files with status = 0.
@yurydelendik
Copy link
Contributor

/botio test

@pdfjsbot
Copy link

pdfjsbot commented Nov 9, 2015

From: Bot.io (Linux)


Received

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

Live output at: http://107.21.233.14:8877/94ccb13e6db12b2/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 9, 2015

From: Bot.io (Windows)


Received

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

Live output at: http://107.22.172.223:8877/0e1c0c68fb76ecb/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Nov 9, 2015

From: Bot.io (Windows)


Success

Full output at http://107.22.172.223:8877/0e1c0c68fb76ecb/output.txt

Total script time: 18.61 mins

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

@pdfjsbot
Copy link

pdfjsbot commented Nov 9, 2015

From: Bot.io (Linux)


Success

Full output at http://107.21.233.14:8877/94ccb13e6db12b2/output.txt

Total script time: 20.26 mins

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

yurydelendik added a commit that referenced this pull request Nov 9, 2015
Improve error message for non-existent local files
@yurydelendik yurydelendik merged commit 3c6df26 into mozilla:master Nov 9, 2015
@yurydelendik
Copy link
Contributor

Thank you for the patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants