Preview panel fails, but separate Chrome tab works fine?

preview

#1

Hi folks,

when I view my code at

https://xxxx-biscuitlad-1.c9users.io/min.html

it works fine. Life would be just a fraction easier if I could view the same code in the preview panel directly in the IDE. However, when I try to do that, I get:

Error in line 139: Uncaught Error: Uncaught SyntaxError: Unexpected token <

I can’t find where this error is, or what causes it in the preview tab, or why it the code works perfectly in a separate Chrome tab but won’t work in the preview tab. They should both be viewing the same file and running the same process?

OK, seems to be the node.js default runner:

Debugger listening on port 15454
/home/ubuntu/workspace/min.html:1
(function (exports, require, module, __filename, __dirname) {
^

SyntaxError: Unexpected token <
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions…js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.runMain [as _onTimeout] (module.js:475:10)
at Timer.listOnTimeout (timers.js:89:15)

When I switch to a fresh apache/php runner, then there’s no error in the console? Getting confused now… :frowning:

thanks


#2

Hi,

I’m afraid we might need more context before we can advise. Can you post part of the javascript file you’re trying to run as the node server? If you could post a screencast showing the issue, that would be awesome! :slightly_smiling:

Regards,
​Mutahhir


#3

It’s a straight github clone of openjscad. If you try to preview either min.html or index.html you’ll hit the same error.


#4

this is a bug in https://github.com/Spiritdude/OpenJSCAD.org/blob/master/openjscad.js#L988
this.baseurl = document.location.href; and then baseurl + “filename” doesn’t work if baseurl has ?foo=bar in it


#5

Why does it work in a separate browser tab? I’ve had this bug a few times with different projects.

If it works in another browser tab perfectly, works perfectly well when installed on a server, I’d suggest it’s your preview in the IDE that needs fixing?


#6

It doesn’t work when you open it with ? in the url
https://preview.c9users.io/nightwing/openjscadorg/min.html?_c9_id=livepreview2&_c9_host=https://ide.c9.io

the url parameters are needed to enable live editing of the preview, you can disable live preview from the preview options menu if you wish

note also that baseurl is handled properly a few lines above the broken code https://github.com/Spiritdude/OpenJSCAD.org/blob/master/openjscad.js#L718


#7

That’s fab, replaced the code you suggested and it works. I’ll suggest that fix to the project developers.
Thanks.