Search code examples
javascriptfirefoxfilereaderweb-workerfileapi

Firefox -- "FileReader is not defined" only when called from Web Worker


In Firefox, the following code works correctly when run in the main browser thread as normal--

var fr = new FileReader();

..but when run from a web worker, the following error is thrown:

FileReader is not defined

The same code works fine in Chrome and Safari.

Any suggestions for supporting FileReader in a web worker in Firefox?


Solution

  • As adeneo pointed out, it seems that FileReader is simply not supported by Firefox in Web Workers. I was able to use FileReaderSync instead to accomplish what I needed.