epubjs-rn
epubjs-rn copied to clipboard
Unhandled promise rejection
Sometimes this error happens when i'm opening an epub.
Error: bind failed: EACCES (Permission denied) at createErrorFromErrorData (blob:http://localhost:8081/29ce852d-6258-406b-a198-eb6e7e1ec87a:sourcemap:2041) at blob:http://localhost:8081/29ce852d-6258-406b-a198-eb6e7e1ec87a:sourcemap:1993 at MessageQueue.__invokeCallback (blob:http://localhost:8081/29ce852d-6258-406b-a198-eb6e7e1ec87a:sourcemap:2435) at blob:http://localhost:8081/29ce852d-6258-406b-a198-eb6e7e1ec87a:sourcemap:2180 at MessageQueue.__guardSafe (blob:http://localhost:8081/29ce852d-6258-406b-a198-eb6e7e1ec87a:sourcemap:2348) at MessageQueue.invokeCallbackAndReturnFlushedQueue (blob:http://localhost:8081/29ce852d-6258-406b-a198-eb6e7e1ec87a:sourcemap:2179) at debuggerWorker.js:70
+1
+1
Facing the same issue. Any solutions ?
same issue here. Any solution?
@yumikohey did you find any solution?
+1
Any Solution ?
The issue here is in the Streamer.js "\node_modules\epubjs-rn\components\Streamer.js" You might need to unminify Streamer.js first.
To do so you can use sites like unminify.com
Here, the localhost port is randomly generated like this this.port = opts.port || "3" + Math.round(Math.random() * 1000);
The value of Math.random() is anywhere between 0 and 1 (inclusive of 0, but not 1) So it works fine most of the time but sometimes when the Math.random() generates value like 0.05, then "this.port" value becomes below 1024. (Ports below 1024 are privilege ports and its not allowed) thus EACCESS Fails. To prevent this you can do something like this
var randPort = 0; do { randPort = Math.round(Math.random() * 1000); } while (randPort < 100) this.port = opts.port || "3" + randPort;
@Nigol496 The solution is working fine. Though we do not need to minify and modify the Streamer.js file. We can do it in the component also and pass the port number as a param to the Steamer class. Like below
``var randPort = 0; do { randPort = Math.round(Math.random() * 1000); } while (randPort < 100) port = "3" + randPort;
this.streamer = new Streamer({port:port});``