Open DaveO-Home opened 5 years ago
I don't totally understand, what is Invalid object
here?
Actually there is an easy way to reproduce this console [Invalid Object] error. Just code;
if (anyUndefinedVar) {
console.warn(anyUndefinedVar);
}
[Invalid Object] show up in the console with nothing else to indicate the problem.
Should you be doing if(typeof anyUndefinedVar !== 'undefined')
there?
Correct, but the point is that deep into to code my example might be mistakenly coded. Very difficult to debug if all that is reported is [Invalid object].
What browser is this? I don't think steal is the cause of the [Invalid object]
error. It's likely coming from the browser. We try to give good error messages that point to the line in the code. So, which browser?
Matthew, The message comes from this; http://localhost:3080/node_modules/steal/steal.js:7341:13
var type = c.error ? "error" : "log";
c[type](error);
I coded console.log(type.trace()) and got this;
ReferenceError: Error evaluating index anyUndefinedVar is not defined
points to the problem... gives me the file and variable.
Steal will log all errors that occur during module execution. It attempts to add additional information to that log to help you track down where in your code the bug occurred. I'm happy to look into using .trace()
if that will help. This article explains how we add more info to the errors: https://www.bitovi.com/blog/donejs-error-handling
However it doesn't work perfectly in every browser. Chrome works better than others, because it gives us more information on where the bug occurred. That's why I asked which browser does this occur in?
I'm sure others work in Fedora, a trace would be good. This also happens with Chrome and Opera. But you are correct, these are Browser builds for Fedora.
Fedora is an OS, right? What is the name of the browser you are using?
Yes, a red-hat Linux flavour, usually on the bleeding edge. Firefox Quantum - 64-bit - Mozilla Firefox for Fedora - fedora-1.0 Chrome - Version 66.0.3359.117 (Official Build) (64-bit)
Thanks for the info! Any small reproducible example would be appreciated, and make it faster for me to fix.
package.json
{
"name": "stealex",
"version": "1.0.0",
"description": "Steal message error",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"Steal"
],
"author": "",
"license": "ISC",
"dependencies": {
"koa": "^2.6.2",
"koa-static": "^5.0.0",
"steal": "^2.1.13"
}
}
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../images/favicon.ico">
<title>StealJS Test Application</title>
</head>
<body>
<test-app>Loading...</test-app>
<script src="./node_modules/steal/steal.js" main="index" data-env="development"></script>
</body>
</html>
koa.js
const serve = require('koa-static');
const Koa = require('koa');
var path = require('path');
const app = new Koa();
app.use(serve(path.join(__dirname, '.')));
app.listen(3000)
console.log("started on 3000");
index.js
if (anyUndefinedVar) {
console.log(anyUndefinedVar)
}
execute; node koa.js browser; localhost:3000/index.html
I find this reliable...
...
var type = c.error ? "error" : "log";
c["count"](error);
c[type](error);
...
How often can you reproduce it?
Description: Steal produces;
when steal encounters an object that it considers invalid. Extremely difficult to debug. Usually if there is a 404 in the server log, that may point to the problem.
Steps to reproduce:
<script src="../../node_modules/steal/steal.js" main="stealjs/appl/main" data-env="development" dev-bundle="../../dev-bundle"></script>
Expected results: If hmr had been previously run, the main web page should load.
Actual results: without existing dev_bundle.js the app will error with;
[Invalid object]
Environment: Steal development mode