Bug 519266 - Tooling not working unless page is refreshed
Summary: Tooling not working unless page is refreshed
Status: ASSIGNED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: JS Tools (show other bugs)
Version: unspecified   Edit
Hardware: PC Mac OS X
: P2 major (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2017-07-05 16:40 EDT by Steve Northover CLA
Modified: 2018-05-15 15:18 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steve Northover CLA 2017-07-05 16:40:20 EDT
1) clone in Web IDE https://github.com/snorthov/minesweeper-objects.git/ 
2) click on app.js.
3) drill into public/js/main.js
4) BUG: there are tons of warning
5) Refresh the page
6) the warnings go away
Comment 1 Michael Rennie CLA 2017-07-06 12:02:01 EDT
There seems to be a timing issue happening here - if I introduce a delay when the loadEagerly entries from the .tern-project file are being loaded, it all works as expected.

Debugging through and it seems that when the bug happens, all of the type infos are in the 'maybe' state in Tern, whereas when you refresh the page it definitively knows the types of Board and Counter.
Comment 2 Steve Northover CLA 2017-07-06 13:11:57 EDT
This worked in the past.  Olivier helped debug it.  You could ask him.  As discussed, please get to the bottom of this ASAP so we can decide next steps.
Comment 3 Michael Rennie CLA 2017-07-06 15:23:33 EDT
(In reply to Steve Northover from comment #2)
> This worked in the past.  Olivier helped debug it.  You could ask him.  As
> discussed, please get to the bottom of this ASAP so we can decide next steps.

I confirmed this is not a regression from 14.

Opening either Board.js or Counter.js also causes the linting to go away. Curtis was the person that worked on this rule last time - and the fix for the linting rule is simple - but the underlying problem is that the types for board and counter are not being made "real" in Tern until they are directly referenced - Tern loads the files correctly, parses / processes them, but since they export into the global scope they are considered "maybe" types.

I am in the process of debugging the type creation / addition strategies to see where the failure is (in Tern).

For what its worth, I also updated to the latest Tern as a test and the problem still exists.
Comment 4 Steve Northover CLA 2017-07-06 15:28:25 EDT
Ok, I guess it happened less often in Orion 14 because this is a pattern I do a lot to quickly check whether the tooling is working.  I'm on the edge of my seat ...
Comment 5 Michael Rennie CLA 2017-07-06 17:11:03 EDT
(In reply to Steve Northover from comment #4)
> Ok, I guess it happened less often in Orion 14 because this is a pattern I
> do a lot to quickly check whether the tooling is working.  I'm on the edge
> of my seat ...

After more testing, it boils down to loading order via the .tern-project file - which affects if the types are made "real".

If you change the .tern-project to:

{
	"libs": ["ecma5"],
	"ecmaVersion": 5,
	"loadEagerly": [
		"public/js/main.js",
		"public/js/board.js",
		"public/js/counter.js"
	]
}

or change the index.html file to (leaving the .tern-project file to load just the html file):

<head>
	<title>Minesweeper</title>
	<link rel="stylesheet" type="text/css" href="css/board.css" />
	<script src="js/main.js"></script>
	<script src="js/counter.js"></script>
	<script src="js/board.js"></script>
</head>

everything works as expected.

I'm still hunting down the code that is causing the unexpected type creation - since it shouldn't matter when the type is loaded (especially since it is not loaded via a modules plugin and is simply exporting a function into the global scope).
Comment 6 Steve Northover CLA 2017-07-06 19:09:39 EDT
Ok, I will use the workaround as necessary.  This really did work at some point recently ... or I was getting lucky on timing.
Comment 7 Steve Northover CLA 2017-08-14 09:39:29 EDT
The work around does not work.  Casey from Google has a cut of Orion in Google Cloud that does not have the problem.  Please coordinate with him to find out when the problem was introduced.
Comment 8 Steve Northover CLA 2017-08-15 15:48:51 EDT
I can't make the problem happen any more.  I'm not sure we should close as WORKSFORME just yet.  I'll try a bit more when I have some time but let's downgrade the priority.
Comment 9 Steve Northover CLA 2017-08-15 15:50:26 EDT
... and I just got it to happen by clicking around.
Comment 10 Michael Rennie CLA 2017-08-16 08:58:52 EDT
(In reply to Steve Northover from comment #9)
> ... and I just got it to happen by clicking around.

Here are some steps I did to make it happen:

1. clone the repo
2. open /public/index.html
3. reload the page
4. open main.js

From this point if you open each of the files (counter.js / board.js) the linting goes away when going back to main.js
Comment 11 Steve Northover CLA 2017-08-16 09:57:44 EDT
Does not happen for me ... how do I know the linting goes away?  Are we both talking about all the warnings that come back down the side?