Skip to content

Commit

Permalink
Add isBrowser to resolve DOMException undefined issue in node
Browse files Browse the repository at this point in the history
  • Loading branch information
jeromewu committed Sep 25, 2019
1 parent b76b7b8 commit 740f2ca
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/common/workerUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const dump = require('./dump');
const { defaultParams } = require('./options');
const { OEM, PSM } = require('./types');

const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';

/*
* Tesseract Module returned by TesseractCore.
*/
Expand Down Expand Up @@ -230,7 +232,7 @@ const handleRecognize = ({
.then(() => (
loadLanguage({ langs, params, options }, res)
.catch((e) => {
if (e instanceof DOMException) {
if (isBrowser && e instanceof DOMException) {
/*
* For some reason google chrome throw DOMException in loadLang,
* while other browser is OK, for now we ignore this exception
Expand Down

0 comments on commit 740f2ca

Please sign in to comment.