ddsol / speedtest.net

node.js SpeedTest.net client module
MIT License
607 stars 125 forks source link

Is it possible to use this library with React Native? #63

Closed ferily7 closed 4 years ago

ferily7 commented 6 years ago

i'm trying to use this speedtest library with React Native to build a mobile app. I specifically want to find the upload and download speed from a certain server and I know that with this library you can do so by inserting the server's id. However, when I try to integrate this into React Native, I can't seem to call the speedTest method and get a TypeError:

Possible Unhandled Promise Rejection (id: 0): TypeError: Network request failed TypeError: Network request failed at XMLHttpRequest.xhr.onerror (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:15825:18) at XMLHttpRequest.dispatchEvent (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:17902:39) at XMLHttpRequest.setReadyState (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:17657:20) at XMLHttpRequest.didCompleteResponse (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:17484:16) at blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:17594:47 at RCTDeviceEventEmitter.emit (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:3480:37) at MessageQueue.callFunction (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:2386:44) at blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:2156:17 at MessageQueue.__guardSafe (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:2348:11) at MessageQueue.callFunctionReturnFlushedQueue (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:2155:14)

Possible Unhandled Promise Rejection (id: 1): TypeError: One of the sources for assign has an enumerable key on the prototype chain. Are you trying to assign a prototype property? We don't allow it, as this is an edge case that we do not support. This error is a performance optimization and not spec compliant. TypeError: One of the sources for assign has an enumerable key on the prototype chain. Are you trying to assign a prototype property? We don't allow it, as this is an edge case that we do not support. This error is a performance optimization and not spec compliant. at Object.assign (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:331:19) at Object.request (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:83858:23) at Object.https.get (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:83871:25) at getHttp (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:87427:16) at getXML (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:87550:11) at nextServer (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:87827:13) at gotServers (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:87833:29) at blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:87386:24 at module.exports. (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:87551:29) at module.exports. (blob:http://localhost:8081/d1e6973c-7f4c-45aa-8bf6-19e7fcddb886:87386:24)

Here is how my two lines of code looks like:

const speedTest = require('./speedtest'); const test = speedTest({maxTime: 5000, serverId : "7334"});

I had to do a workaround to import the node module in React Native which works perfectly. I don't get an error when I do require, but right when I call the speedTest is when I get the above error. Does anyone have any thoughts or two cents with this issue?

ddsol commented 4 years ago

The latest version uses the official CLI so this is not possible (unless you modify the previous version).