Android-runtime: Worker crashing issue & call stack error

Created on 9 Nov 2016  路  4Comments  路  Source: NativeScript/android-runtime

Please, provide the details below:

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.

Please provide the following version numbers that your issue occurs with:

v2.4.0 as of 11/7 (both core modules and android runtimes)

Did the error happen while the app was being constructed? (buildtime error)

No

Did the error happen while the app was executing? (runtime error)

Yes

Please tell us how to recreate the issue in as much detail as possible.

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);
};
bug

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. ;-)

All 4 comments

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:

  • var debug_1 = require("ui/core/view"); //builder.js
  • var viewCommon = require("./view-common"); //view.js
  • var style = require("../styling/style"); //view-common.js
  • var application = require("application"); //stype.js

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. ;-)

Was this page helpful?
0 / 5 - 0 ratings