Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Duplicate atom key warning when used from multiple bundles #213

Closed
atanasster opened this issue May 31, 2020 · 15 comments
Closed

Duplicate atom key warning when used from multiple bundles #213

atanasster opened this issue May 31, 2020 · 15 comments

Comments

@atanasster
Copy link

For 0.0.8, I am getting the following blocking error (was working fine with 0.07):

recoil.development.js:117 Uncaught TypeError: Cannot destructure property 'error' of 'undefined' as it is undefined.

Two issues afaics:

  1. It displays the wrong error, since there isnt a third parameter in the call from registerNode:
    recoverableViolation(message, 'recoil');
  2. The actual error (Duplicate atom key ..) it wants to display is not correct, since I have only one of this key registered (it is not duplicated), however the package is called from two bundles.
@drarmstr drarmstr linked a pull request May 31, 2020 that will close this issue
@atanasster
Copy link
Author

@drarmstr thanks for linking this issue to a PR. However I also have a second part - that the error 'Duplicate atom key .' is not correct.

Should I file a new issue about that, or do you have any feedback on this?

@Shmew
Copy link

Shmew commented Jun 1, 2020

Are you using HMR? That will trigger that error I believe.

@atanasster
Copy link
Author

I am using hmr however the error shows without hmr being invoked (no files are changed, just loading the app generates the error)

@drarmstr
Copy link
Contributor

drarmstr commented Jun 5, 2020

@atanasster I don't think we've seen the duplicate key issue outside of HMR, but it sounds like it may be due to the atom being created twice from the two bundles?

@drarmstr drarmstr changed the title 0.0.8 registerNode issues Duplicate atom key warning when used from multiple bundles Jun 19, 2020
@drarmstr
Copy link
Contributor

@atanasster - Please re-open this issue if you continue to see a problem without HMR.

@hmtri1011
Copy link

image
Hi all, I got this warning when trying Recoil with NextJS. This happens every time I try refresh with new page.

I think it might be HMR problem because it happened on development only, but I want to know how I do a singleton pattern for atom to prevent this warning on development.

Thanks!

@martinop
Copy link

any news?

@parweb
Copy link

parweb commented Nov 3, 2020

time to re-open the issue :/

@rosko
Copy link

rosko commented Nov 7, 2020

Experiencing the same issue as @hmtri1011 described.

@deshario
Copy link

@hmtri1011 Any solution ?

@anoveskey-dte
Copy link

I felt it's worth mentioning this. If you declare your atom/selector inside the same file it is being used, you will see this warning whether your have hot module replacement enabled or not. It is best to import it.

@ivanjeremic
Copy link

I felt it's worth mentioning this. If you declare your atom/selector inside the same file it is being used, you will see this warning whether your have hot module replacement enabled or not. It is best to import it.

Do you mean this for Nextjs? I try to somehow solve this issue in my Nextjs project is there any way of doing this currently?

@juanpprieto
Copy link

juanpprieto commented Mar 5, 2021

I'd love to be able to suppress these warnings in NextJS too.

I get the warnings both during dev (prob due to HMR) and also during build time (much more noticeable) I assume thats because it's included in common chunks that next adds to every statically generated route.

However, in both instances everything seems to work just fine.

P.S - When I used recoil in Gatsby (fully statically generated), I didn't have this problem, so it's prob something to do with the way NextJS handles bundling and SSR

Thanks!

@oSethoum
Copy link

Any update on this issue ?

@juanpprieto
Copy link

Any update on this issue ?

Dirty workaround here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.