Error: Cannot resolve callback 1 when opening multiple pdfs
See original GitHub issueLink to PDF file (or attach file here):
pdf-sample.pdf compressed.tracemonkey-pldi-09.pdf
Configuration:
- Web browser and its version: Chrome 56.0.2924.87
- Operating system and its version: OSX 10.11.6
- PDF.js version: pdfjs-dist 1.7.414
- Is an extension: No
Using following React component:
import React, { Component } from 'react';
import PDFJS from 'pdfjs-dist/webpack';
class App extends Component {
constructor() {
super();
this.state = {pdfs: []};
this.handleInputChange = this.handleInputChange.bind(this);
}
handleInputChange(event) {
const file = event.target.files[0];
const reader = new FileReader();
const self = this;
reader.onload = function() {
const typedArray = new Uint8Array(this.result);
PDFJS.getDocument(typedArray).then(pdf => {
self.setState({pdfs: self.state.pdfs.concat(pdf)});
});
};
reader.readAsArrayBuffer(file);
}
render() {
return (
<div>
<input type="file" onChange={this.handleInputChange}/>
<ul>
{this.state.pdfs.map((pdf, i) => <li key={i}>{pdf.numPages}</li>)}
</ul>
</div>
);
}
}
Steps to reproduce the problem:
- Upload first attached PDF
- Upload second attached PDF
What is the expected behavior? Both PDFs’ page counts are printed:
What went wrong? The expected behavior occurs, but PDF.js throws the following error when a second PDF is opened, and will throw the error again whenever a new PDF is opened:
Error: Cannot resolve callback 1
pdf.js:340 at error (http://localhost:3000/static/js/bundle.js:33026:18)
at MessageHandler.messageHandlerComObjOnMessage (http://localhost:3000/static/js/bundle.js:33732:10)
(specifically, from line https://github.com/mozilla/pdf.js/blob/59392fd5442d819879dc7ec0a0a8ce9a2fbd2f71/src/shared/util.js#L1291)
This appears unrelated to the contents of the PDFs, this occurs with any sequence of multiple PDFs I’ve tried other than opening the same file twice.
If I call pdf.destroy()
on the already-open PDF before opening another, this does not occur.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top GitHub Comments
@yurydelendik I published a complete minimal project here: https://github.com/gdaolewe/webpack-pdfjs-repro
@rvinay88 @mattnetto can you publish complete project (instead of snippets of code)?