http-server icon indicating copy to clipboard operation
http-server copied to clipboard

Server / page hangs when I have template strings in a script / tag (js-ish) file.

Open jmk2142 opened this issue 9 years ago • 3 comments

Strange bug. Not sure it's an http-server issue, maybe a bug in a dependency as I can generate the same problem in various server solutions (e.g. reload, lr-http-server, etc.) Anyway, thought maybe someone here might have a better insight. I'm using RiotJS and http-server / watch-http-server to develop. My page stopped responding when I started using template strings in my file.

I'm loading the files in an index.html like this:

screen shot 2017-04-02 at 7 10 51 pm

What happens is when I include a template string like this in my tag file (comments-mine.tag):

screen shot 2017-04-02 at 7 00 14 pm

The Network panel gives me a warning: Caution: request is not finished yet!

screen shot 2017-04-02 at 7 01 32 pm

This hangs the page. Nothing in the browser window will work until the hang frees itself. With one or two of these template string lines, the page will eventually (after a long delay) become responsive again. However, with many of these - the browser will try to kill the page.

I've duplicated this issue in Firefox as well. By simply commenting out the template string and replacing it with string cats, the page loads fine, see image:

screen shot 2017-04-02 at 7 06 49 pm

Result:

screen shot 2017-04-02 at 7 07 50 pm

Any ideas where the issue lies?

EDIT: Seems to change the outcome if I add more or less ${} in the line. Or / chars. Or whether it's inside [ ... ]. Something in the way the server is parsing the raw stuff it transfers? See examples:

Hangs (one ${...})
updates[`comments/public/${comment.id}/`] = comment;

Works
updates[`comments/public/${comment.id}`] = comment;

Hangs (two ${...})
updates[`users/${user.uid}/${comment.id}`] = comment;

Works
updates[`users/${user.uid}/${comment.id}/`] = comment;

Template String Pattern outside of brackets [...]
Works (this pattern hangs if in brackets)
var publicRefStr = `comments/public/${comment.id}/`;
updates[publicRefStr] = comment;

Hangs (two ${...} still)
var userRefStr = `comments/users/${user.uid}/${comment.id}`;
updates[userRefStr] = comment;

Works (two ${...})
var userRefStr = `comments/users/${user.uid}/${comment.id}/`;
updates[userRefStr] = comment;

jmk2142 avatar Apr 02 '17 23:04 jmk2142

Pretty confident this isn't an http-server related issue. Feel free to open a re-open this if you can narrow the bug down to something directly http-server related. Thanks!

BigBlueHat avatar Apr 25 '17 14:04 BigBlueHat

Yeah. Figured. Any idea as to which dependency might be a good place to start hunting this down?

jmk2142 avatar Apr 25 '17 15:04 jmk2142

@jmk2142 something frontend / template related, I'd reckon.

BigBlueHat avatar Apr 25 '17 15:04 BigBlueHat