If you worker file somehow in the require's manages to pull in the ui/builder/builder.js then the worker will spit out an error to the onerror handler (and die):
Error: Uncaught TypeError: Cannot read property 'prototype' of undefined
Stack Trace: Line 1 of undefined.
v2.4.0 as of 11/7 (both core modules and android runtimes)
No
Yes
Worker File:
require('globals');
console.log("Worker starting");
require('ui/builder/builder.js');
console.log("Worker included everything"); // Not printed
Main File
var worker = new Worker('worker');
worker.onerror = function(msg) {
console.dump(msg);
};
Hi @NathanaelA,
The problem is the require('ui/builder/builder'); module can't be required by itself because it's dependent on the application module down the require line:
Because some modules require the application modules to be required first (including this one), you can't escape from ding require("application").
The solution to your problem is requiring application module before require('ui/builder/builder.js');.
You can open an issue in the module's repo if you want the builder module to be "stand-alone".
I'll have to check this. So application can be safely included in the worker threads... Thanks!
Is there any way you can provide a better error than:
Error: Uncaught TypeError: Cannot read property 'prototype' of undefined
Stack Trace: Line 1 of undefined.
@NathanaelA, absolutely valid point, but it's part of the effort of making the modules self-contained.
@Plamen5kov - So is there is some way to go up the stack trace to find the calling function of the module in the workers? Having the final error as-is is fine as long as I get a FULL stack trace too. Right now the error is pointless as it doesn't point to ANYTHING and can't easily be determined what the issue is since the error and stack trace is just that single Line 1 of undefined.
So right now it just displays only the very top most error, but doesn't bother descending the stack to get the caller/caller line number that get you to that point. If the stack trace worked the same way in the workers as the main thread; then I would be able to see the error was caused by builder.js calling view-common, calling style, calling application. ;-)
Most helpful comment
@Plamen5kov - So is there is some way to go up the stack trace to find the calling function of the module in the workers? Having the final error as-is is fine as long as I get a FULL stack trace too. Right now the error is pointless as it doesn't point to ANYTHING and can't easily be determined what the issue is since the error and stack trace is just that single
Line 1 of undefined.So right now it just displays only the very top most error, but doesn't bother descending the stack to get the caller/caller line number that get you to that point. If the stack trace worked the same way in the workers as the main thread; then I would be able to see the error was caused by builder.js calling view-common, calling style, calling application. ;-)