Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logger.replace in cjs yarn monorepo doesn't work if called from another package #1548

Closed
sukovanej opened this issue Oct 23, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@sukovanej
Copy link
Contributor

sukovanej commented Oct 23, 2023

What version of Effect is running?

2.0.0-next.50

What steps can reproduce the bug?

When testing a cjs monorepo package using vitest, e.g. Logger.replace doesn't have any effect when it's being called from a different package than the one being tested.

Repro: https://github.com/sukovanej/effect-cjs-yarn-monorepo-repro/

What is the expected behavior?

combinators manipulating fiber refs can be defined in different cjs packages and used with vitest

What do you see instead?

No response

Additional information

No response

@sukovanej sukovanej added the bug Something isn't working label Oct 23, 2023
@mikearnaldi
Copy link
Member

cc @Andarist - This is caused by dual-package hazard, even though effect is built with preconstruct (at the moment). What happens here is that we forgot to define loggers as global so two instance of defaultLogger are created and replace doesn't work, we can fix it by using a global for loggers but it's strange because this should not occur in the first place. Maybe vitest prefers the pure modules and ignores the esm proxy modules?

@Andarist
Copy link
Contributor

Vitest is using some weird strategy of bundling/resolving some things on its own but yet leaving some other things for node to resolve. I didn't dig deep enough to know what exact heuristic they are using to do this (they use workers so call stacks are not that useful) but I'm pretty sure of that conclusion. I couldn't observe effect's resolution from pkg-1 to go through Vite's resolveId function (which indicates that they didn't resolve it and left it to node). At the same time, I was able to "force" it to go through that after adding package.json#exports.{module,default} (and appropriate ESM file) to pkg-1/package.json.

I think this should be reported to the Vite team regardless of how you decide to resolve it here. From my PoV, this is clearly an issue on their side.

@mikearnaldi
Copy link
Member

This is solved on our side, keeping it open as a reference to track vitest

@sukovanej
Copy link
Contributor Author

Confirming the problem resolved on my end after the effect update. Thanks!

@DadeSko DadeSko moved this to Created in Issues Management Jan 29, 2024
@tim-smart tim-smart moved this from Created to Active Discussion in Issues Management Mar 19, 2024
@tim-smart
Copy link
Contributor

Upstream vitest closed the issue - I don't think there is any further action needed here?

@fubhy fubhy closed this as completed Apr 3, 2024
@github-project-automation github-project-automation bot moved this from Active Discussion to Done in Issues Management Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

5 participants