Merge pull request #8959 from Snuffleupagus/api-worker-version-check
Ensure that the same exact version of PDF.js is used in both the API and the Worker
This commit is contained in:
commit
25806d17f4
@ -364,6 +364,15 @@ var WorkerMessageHandler = {
|
|||||||
var cancelXHRs = null;
|
var cancelXHRs = null;
|
||||||
var WorkerTasks = [];
|
var WorkerTasks = [];
|
||||||
|
|
||||||
|
let apiVersion = docParams.apiVersion;
|
||||||
|
let workerVersion =
|
||||||
|
typeof PDFJSDev !== 'undefined' ? PDFJSDev.eval('BUNDLE_VERSION') : null;
|
||||||
|
// The `apiVersion !== null` check is needed to avoid errors during testing.
|
||||||
|
if (apiVersion !== null && apiVersion !== workerVersion) {
|
||||||
|
throw new Error(`The API version "${apiVersion}" does not match ` +
|
||||||
|
`the Worker version "${workerVersion}".`);
|
||||||
|
}
|
||||||
|
|
||||||
var docId = docParams.docId;
|
var docId = docParams.docId;
|
||||||
var docBaseUrl = docParams.docBaseUrl;
|
var docBaseUrl = docParams.docBaseUrl;
|
||||||
var workerHandlerName = docParams.docId + '_worker';
|
var workerHandlerName = docParams.docId + '_worker';
|
||||||
|
@ -331,6 +331,8 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||||||
if (worker.destroyed) {
|
if (worker.destroyed) {
|
||||||
return Promise.reject(new Error('Worker was destroyed'));
|
return Promise.reject(new Error('Worker was destroyed'));
|
||||||
}
|
}
|
||||||
|
let apiVersion =
|
||||||
|
typeof PDFJSDev !== 'undefined' ? PDFJSDev.eval('BUNDLE_VERSION') : null;
|
||||||
|
|
||||||
source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
|
source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
|
||||||
source.disableStream = getDefaultSetting('disableStream');
|
source.disableStream = getDefaultSetting('disableStream');
|
||||||
@ -341,6 +343,7 @@ function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
|
|||||||
}
|
}
|
||||||
return worker.messageHandler.sendWithPromise('GetDocRequest', {
|
return worker.messageHandler.sendWithPromise('GetDocRequest', {
|
||||||
docId,
|
docId,
|
||||||
|
apiVersion,
|
||||||
source: {
|
source: {
|
||||||
data: source.data,
|
data: source.data,
|
||||||
url: source.url,
|
url: source.url,
|
||||||
|
Loading…
Reference in New Issue
Block a user