Comments (13)
Hey Austin - glad to report that 4.0 works fine! I haven't gotten it working with webworker-thread yet, but I'm sure that will come.
Thanks again for your help!
from hamsters.js.
Interesting, I'll have to take a look at it here soon. The issue appears to be that Node doesn't like using self
as a shortcut to the global scope, typically self.blah
would be the same as global.blah
or window.blah
so node is doing something weird.
I'd suggest trying to use a 3rd party web worker implementation as well, something like this might help you get started before I can address this as its an issue with the legacy fallback mode that doesn't actually use threads. https://www.npmjs.com/package/webworker-threads
Node doesn't ship with a native web worker implementation out of the box so the library is defaulting to the fallback mode in your case. If you make use of a third party implementation be sure to import that BEFORE you import hamsters.
from hamsters.js.
from hamsters.js.
@csterritt Try using the latest from dev branch now, just pushed this commit which should fix the issue. I haven't tested it yet but it looks like it'll work.
from hamsters.js.
@csterritt Please let me know if that resolved your issue if you get the chance, thanks
from hamsters.js.
from hamsters.js.
@csterritt No problem, I'm going to go ahead and close this issue out. I went ahead and published v3.9.8 which includes this fix. If you have anymore issues feel free to open another ticket, thanks!
https://github.com/austinksmith/Hamsters.js/releases/tag/v3.9.8
from hamsters.js.
Sorry to be 'that guy', but I'm getting a new problem with v3.9.8. It fails the same way under node v4.3.2 and v7.7.0:
/Volumes/Second/Chris/myprogram/node_modules/hamsters.js/src/es5/hamsters.js:312
hamsters.wheel.hamsters.push(new Worker('src/common/wheel.min.js'));
^
ReferenceError: Worker is not defined
at spawnHamsters (/Volumes/Second/Chris/myprogram/node_modules/hamsters.js/src/es5/hamsters.js:312:44)
at /Volumes/Second/Chris/myprogram/node_modules/hamsters.js/src/es5/hamsters.js:963:7
at setupHamstersEnvironment (/Volumes/Second/Chris/myprogram/node_modules/hamsters.js/src/es5/hamsters.js:112:5)
at /Volumes/Second/Chris/myprogram/node_modules/hamsters.js/src/es5/hamsters.js:907:3
at Object.<anonymous> (/Volumes/Second/Chris/myprogram/node_modules/hamsters.js/src/es5/hamsters.js:966:3)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
from hamsters.js.
No problem, that's why I asked you to follow up haha. So it looks like I mixed up the order during the environment setup so currently the v3.9.8 will only work with a 3rd party web worker implementation (which is what you'll want for real threading). I'll push a fix today that will restore the legacy fallback mode which will allow you to write your logic and take advantage of the async nature of the library but will not give you the performance benefits you're probably looking for with extra threads.
from hamsters.js.
As promised, this should resolve your issues. Runkit on npm hasn't updated yet but i think this will work.
https://github.com/austinksmith/Hamsters.js/releases/tag/v4.0.0
from hamsters.js.
Alas:
/Volumes/Second/Chris/myprogram/node_modules/hamsters.js/src/es5/hamsters.js:102
setupNodeSupport();
^
ReferenceError: setupNodeSupport is not defined
at setupHamstersEnvironment (/Volumes/Second/Chris/myprogram/node_modules/hamsters.js/src/es5/hamsters.js:102:7)
at /Volumes/Second/Chris/myprogram/node_modules/hamsters.js/src/es5/hamsters.js:909:3
at Object.<anonymous> (/Volumes/Second/Chris/myprogram/node_modules/hamsters.js/src/es5/hamsters.js:968:3)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Volumes/Second/Chris/myprogram/build/try-parallel.js:3:17)
Also, which 3rd party web worker implementation do you recommend?
from hamsters.js.
Hmm, so I actually published version 4.0 which resolves the issue you're talking about already. I see on the npmjs.com page that it shows version 4.0 is what you should see. This however looks like version 3.9.9.
from hamsters.js.
I put in a support ticket with them to get the website to update the package, sorry about that. Regarding web worker implementations, this one looks fairly good. I will warn however that their example documentation isn't what you probably want here. You'll probably need to do something like this.
require('webworker-threads');
require('hamsters.js');
Then you can just use Hamsters like you usually would. If you get an error that Worker doesn't exist..then do what their documentation says and assign a global variable to assign Worker
.
global.Worker = require('webworker-threads').Worker;
require('hamsters.js');
from hamsters.js.
Related Issues (20)
- Uncaught ReferenceError: adTestentListener is not defined HOT 1
- Tests not pasing HOT 1
- React-native android side, typeerror using hamsters and react-native-threads HOT 18
- how to migrate from v4 to v5 HOT 18
- Promises error HOT 15
- rtn data is pushed on different index than 0 HOT 19
- Windows 10 | Node.js - no output when using hamsters.js + webworker-threads package HOT 13
- The examples in the website don't have the source code of the example HOT 2
- Cannot read property 'buffer' of undefined." HOT 4
- im not getting correct results from the rtn.data object in hamsterjs v5.1.3 HOT 21
- Pointers for use with ReactJS HOT 2
- react-native-threads not working. HOT 2
- react native workers HOT 4
- ERROR: while initiating hamsters.js [React Native] HOT 5
- Your country is blocked from accessing this content. HOT 1
- http://www.hamsters.io/ offline HOT 2
- Anyone use hamesters.js successfully in Chrome Browser ? HOT 3
- Uncaught TypeError: hamsters.run is not a function HOT 3
- rtn undefined HOT 4
- react-native-hamsters/example - undefined is not an object (evaluating 'message.data.data') HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hamsters.js.