Skip to content
This repository was archived by the owner on Nov 4, 2024. It is now read-only.

reference mismatch with esm imports and hapijs/lab #524

Closed
dnalborczyk opened this issue Jul 27, 2018 · 10 comments
Closed

reference mismatch with esm imports and hapijs/lab #524

dnalborczyk opened this issue Jul 27, 2018 · 10 comments

Comments

@dnalborczyk
Copy link
Contributor

Just for fun I pulled down and converted hapi to use es modules with esm, and to my surprise, the test suite running with lab converted to use es-modules worked out-of-the-box with esm as well !! Really amazing!!! 😃

the test suite produced one single bug. Not sure if that is a lab-specific issue.

repro in the works ...

speaking of amazing: debugging the failed test case with ndb was short of amazing as well!! just worked out-of-the-box with esm!!

@jdalton
Copy link
Member

jdalton commented Jul 27, 2018

Thanks for digging in! Do you know off hand what the reference mismatch was with.
I've seen it in the past with some things so have some idea.

@dnalborczyk
Copy link
Contributor Author

dnalborczyk commented Jul 27, 2018

I literally thought I had it ... and then it slipped away.
sometimes I have the feeling esm is self-healing 😃

I might have to check in the converted hapi repo for you to have a look at.

edit:

I think I found the culprit. I think I was "double loading" esm through api and cli. some tests pointed to the bridge, while others didn't (cli). might still be a bug. still looking ...

@dnalborczyk
Copy link
Contributor Author

here is a repo of the above "issue", although I'm not sure if it really is an issue - but it might help to uncover some underlying or hidden problem when esm is being used programmatically and with the cli.

https://github.com/dnalborczyk/esm-repros/tree/issue-524

when you run the tests with npm test, they will pass. you have to comment out this line to make it fail.

@jdalton
Copy link
Member

jdalton commented Jul 27, 2018

Cool. What version of Node are you testing on?

@dnalborczyk
Copy link
Contributor Author

dnalborczyk commented Jul 27, 2018

sorry, latest, v10.7.0

btw, forgot to mention: it really is 1 test, the other "empty" test can easily be removed. just didn't wanna confuse you.

edit: just noticed that the repo is using a mix of Stream function and a Stream property on the Stream function, but I believe both are the same: require('stream') === require('stream').Stream

@dnalborczyk
Copy link
Contributor Author

btw, the hapi tests with lab are fully succeeding!!

@jdalton don't spend any time on this if you see no value. it's clearly being used in a way it wasn't meant to be.

@jdalton
Copy link
Member

jdalton commented Jul 28, 2018

This is an interesting issue in how we share and access state. It's a legit bug. In the deferred getter for the builtin entries I don't check if the entry has already been created (I assume if it had a deferred getter added that means it wasn't found in the cache). However, in this case the deferred getter is added in one place and before the getter is tripped (to create the entry) the entry is created in another.
Checking the builtin cache before creation on the getter resolves the issue.

@jdalton
Copy link
Member

jdalton commented Jul 28, 2018

test debt 💰💰

Update:

@dnalborczyk I'm adding a new label to issues that I have not added tests for. You can follow along with this query. We'll remove the label from issues as the test addition PRs are merged.

@dnalborczyk
Copy link
Contributor Author

@jdalton good idea! 👍

@jdalton
Copy link
Member

jdalton commented Aug 3, 2018

@dnalborczyk I fixed the query link. Some of them, like the Electron ones, aren't practical to test in an automated way but are good to be aware of.

Update:

v3.0.73 is released 🎉

@jdalton jdalton added the bug label Aug 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

2 participants