Closed Bug 1346482 Opened 7 years ago Closed 7 years ago

circular module import (es modules - import {member1, member2} from "module-name";)

Categories

(Core :: JavaScript Engine, defect)

Unspecified
Windows 10
defect
Not set
critical

Tracking

()

RESOLVED DUPLICATE of bug 1388728

People

(Reporter: deltaescolarrs, Unassigned)

References

Details

Crash Data

Attachments

(7 files, 2 obsolete files)

This bug was filed from the Socorro interface and is 
report bp-436e6355-8c71-4a0a-875e-8584b2170311.
=============================================================


Problem with circular module import (es modules - import {member1, member2} from "module-name"; . There are no errors on the console. All modules are loaded in the network tab, but the Degugger tab does not show all modules. The application does not render or firefox displays: Aff! your tab froze.

By disabling the circular link, the application works properly.

Bug writing guidelines

If you have precise steps to reproduce?
Yes, just enable some circular import inside the application that stops it from working.

I can reproduce with Firefox 54 Developer Edition or Firefox 55 Nightly

The same application, with circular links, works correctly with SystemJS systemjs_0.20.9 + babel plugin 0.0.21.
Without circular modules, all is working.
Attached image withCircularModules.png
With circular import the SPA don't render and the console don't show error.

Not all modules fetched in the Network tab are listed in the Debugger tab.
Could you provide a simple testcase to reproduce the issue, please.
Flags: needinfo?(deltaescolarrs)
Attached file Delta Schools Webjs Sample.rar (obsolete) —
Steps

No server required.

1) To enable the ES modules:

    open the about:config page
    press “I accept the risk!”
    search for a dom.moduleScripts.enabled boolean flag
    double click to change its value to “true”

2) To simulate the problem, uncomment lines 1 and 26 in the school.js file.

Note: this example was reduced from an application only to test this issue and was tested with firefox 54.0a2 developer edition (2017-03-12) 64bits
Attached file Delta Schools Webjs Sample.zip (obsolete) —
Sorry, lines 1 and 24
Flags: needinfo?(deltaescolarrs)
I guess there is a typo in "school.js", it should be:
import {formLogin} from './login.js';
instead of:
import {formLogin} from './formLogin.js';

With this change, I see the form and the alert box "it works", but no crash with FF55 32/64b on Win 7.
Loic

Unfortunately I did not see the typo exactly in a crucial line for the test.

In this way, I was led to think that the example was perfect to demonstrate the problem.

This invalidated the example, it really works, the example is extremely simple, and maybe I can not reproduce the problem in a very simple example.

On the other hand, in the application I'm working currently, it has about 15 modules (still simple but with more features).

In each module, there is more than one import. It has extra functions that are consumed within the exported functions, has calls to server resources using fetch and callback functions to process the JSON result.

Then we can think, could have a problem in the code, in the structure. Yes, it could.
But we can also think: and how to explain that with SystemJS the application works?

I do not see how, at the moment, I could create a simpler example in which I can simulate the problem.

One possibility would be to provide access to my PC with Team Viewer / Show My PC.

Also, I'll modify the example to include indirect importing.

The A calls B, B calls C, C calls A.


Another idea, it would be some Brazilian of the team, if there is one, to contact me, since I am not fluent in English.
Did you test your reduced testcase on your machine locally? If yes, are you able to reproduce the hang/crash?

I'm not saying the issue is not here, but with the reduced testcase you linked, I can't reproduce it.
Loic

The problem could also be elsewhere

I'm going to list some candidates:

A) In my code, because there is still no expertize and community to exchange experiences involving programming with modules

B) In the Fetch API

C) In Firefox Nightly or developer (because it is not stable)

D) In instantiation of the modules

But I think, as all files are loaded:
The algorithm responsible for importing is PROBABLY CORRECT
The Fetch API is PROBABLY CORRECT

The most plausible is that there is some problem regarding instantiation of the modules, especially those with circular reference. Maybe the engine would be trying to re-instantiate

I'm incrementing the example with more modules, more relationships between them, to see if I can reproduce the problem.

But without using an http server, I'm not sure I'll be able to.

It is very difficult to surround / isolate the problem, as there are no log errors or exceptions in the JS code. And yet, all files are loaded on the network tab.

Hope lies in the testcase.

I'll be back soon.
Yes, the hang may appear with more complexity in the code. Don't hesitate to attach a testcase if you're able to craft a test to reproduce it.

If you're allowed to do that, you can even put your -webapp on a testing server and provide the URL by email (even with guest credentials).
Attachment #8846639 - Attachment is obsolete: true
Attachment #8846640 - Attachment is obsolete: true
Loic

In this new testcase (above), firefox issues an error as the attached image

Steps to Reproduce

Clear the cache
Tools >> options >> advanced >> Network tab >> web content cache and click clean button
Restart the pc or turn it off and on again

Open the index.html file in firefox and it will not render and will show the image error in the console

But then, by pressing
Enter
Or reload
F5 or Ctrl + R or Reload Button
Or reload (override cache)
Ctrl + F5 or Ctrl + Shift + R or Shift + Reload Button

The application works and stops issuing the error.

I do not know if it would be the same case when working with an http server.
Loic, did you get reproduce the issue with the new testcase?

On the other hand, running with firefox nightly 2017/04/05 (not local) I get a new message, as picture.
No success for me.
Blocks: modules-0
The problems with circular module imports should have been fixed by bug 1388728.

I tried the attached testcase and it worked for me in the latest nightly, loading the modules and displaying a login form.  I didn't see any errors.

I'm closing this bug - if this is still not working then please re-open.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: