donejs / done-component

A plugin for creating <can-component>s
https://www.npmjs.com/package/done-component
MIT License
8 stars 2 forks source link

Unhandled Promise Rejection in component.js (TypeError: Module is already loading) #103

Open kcarmonamurphy opened 5 years ago

kcarmonamurphy commented 5 years ago

I'm getting the following error in my console when running donejs develop:

TypeError: Module is already loading.
    at Loader.define (/Users/kcarmonamurphy/Projects/ting-node-upgrade/node_modules/steal/src/loader/loader.js:1082:15)
    at file:/Users/kcarmonamurphy/Projects/ting-node-upgrade/node_modules/done-component/component.js:229:16
(node:2512) UnhandledPromiseRejectionWarning: TypeError: Module is already loading.
    at Loader.define (/Users/kcarmonamurphy/Projects/ting-node-upgrade/node_modules/steal/src/loader/loader.js:1082:15)
    at file:/Users/kcarmonamurphy/Projects/ting-node-upgrade/node_modules/done-component/component.js:229:16
(node:2512) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:2512) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Starting on line 226 in component.js, we can see that there is no .catch() block:

                    if(typeof defn.source !== "string") {
                        return Promise.resolve(defn.source)
                            .then(function(source){
                                loader.define(moduleName, source, {
                                    address: address(defn.name),
                                    metadata: defn.metadata
                                });
                            });
                    }

I would gladly help write up a PR for this but I'm not sure what the best way to handle any errors would be here. Simply output error message to console or try to dig deeper to find root cause of error (or both?). Looking for some guidance.

matthewp commented 5 years ago

How does the promises not being resolved relate to Module is already loading. error?

justinbmeyer commented 5 years ago

Anyway you can push the code that creates this to a repo that we can see?

matthewp commented 5 years ago

I saw something similar in a local donejs-chat app so I'm going to take a look. I saw this happening in live-reload, not sure if that's when you did.

matthewp commented 5 years ago

Really need a reproducible case in order to fix this.

kcarmonamurphy commented 5 years ago

Really wish I could provide you with more information regarding this specific issue, but generally we're trying to upgrade from canjs3 to canjs4 and ideally from steal1 to steal2. all permutations of package versions that we've bumped up have been giving us different errors and we've been losing track of what package upgrade causes what error.

I need to liaise with my team but likely (it's my hope) that we'll be able to send you our whole repository so that you could take a look and help us with the upgrade. feel free to close this issue in the meanwhile.