Skip to content

I have an error when make debug build. (error node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js: #<WeakSet> could not be cloned.) anyone have this error #31413

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

Closed
Rananjaya opened this issue Apr 23, 2021 · 15 comments
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@Rananjaya
Copy link

error node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js: # could not be cloned. Run CLI with --verbose flag for more details.
Error: # could not be cloned.
at Object.serialize (v8.js:202:7)
at _default (/home/rananjaya/Desktop/child_app/ch/node_modules/@babel/core/lib/transformation/util/clone-deep.js:16:30)
at normalizeFile (/home/rananjaya/Desktop/child_app/ch/node_modules/@babel/core/lib/transformation/normalize-file.js:52:36)
at normalizeFile.next ()
at run (/home/rananjaya/Desktop/child_app/ch/node_modules/@babel/core/lib/transformation/index.js:31:50)
at run.next ()
at /home/rananjaya/Desktop/child_app/ch/node_modules/@babel/core/lib/transform-ast.js:20:41
at Generator.next ()
at evaluateSync (/home/rananjaya/Desktop/child_app/ch/node_modules/gensync/index.js:251:28)

@Rananjaya Rananjaya changed the title I have an error when make debug build. (error node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js: #<WeakSet> could not be cloned.) I have an error when make debug build. (error node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js: #<WeakSet> could not be cloned.) anyone have this error Apr 23, 2021
@klaaz0r
Copy link

klaaz0r commented May 2, 2021

I have a similar issue with all kinds of modules

@siderakis
Copy link

oblador/react-native-vector-icons#1334

@japhet247
Copy link

I think the problem might be with @babel/core and @babel/runtime versions. I downgraded to the below versions and it worked for me;

"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",

@dennislky
Copy link

Sadly, I am still with the same issue, and doesn't find a way out.

For me, it seems the problem is when babel (react native by default is using metro-react-native-babel-preset) trying to transform file, it requires to deep clone the value, and it is using v8.deserialize(v8.serialize(value)) to do that; however, in some versions of v8, the file have been recognized as WeakSet, and therefore threw the DataCloneError.

I have tried several ways, including changing the clone method as per the following code suggested by @amiller-gh
const { MessageChannel, receiveMessageOnPort } = require('worker_threads'); const { port1, port2 } = new MessageChannel(); function structuredClone (o) { port1.postMessage(o); return receiveMessageOnPort(port2).message; }
And was suspecting v8 version difference between different node versions (v12.22.1, v14.16.1, v16.0.0), and the difference between JavaScriptCore and v8, but it seems all are not the case.

Would anyone have other workarounds that may be useful? Thanks in advance!

@jmikulka
Copy link

jmikulka commented May 4, 2021

As @japhet247 suggested, downgrading @babel/core and @babel/runtime versions fixes the problem.

See oblador/react-native-vector-icons#1334 (comment).

@dennislky
Copy link

Hi @jmikulka, thanks for the reply, I had tried with @japhet247's answer too, and I had even tried downgrading React Native version back to 0.63.4 with the corresponding dependencies, and still the same case, successfully compiled, but got the #<WeakSet> could not be cloned. error during bundling stage.

@jmikulka
Copy link

jmikulka commented May 5, 2021

Hi @jmikulka, thanks for the reply, I had tried with @japhet247's answer too, and I had even tried downgrading React Native version back to 0.63.4 with the corresponding dependencies, and still the same case, successfully compiled, but got the #<WeakSet> could not be cloned. error during bundling stage.

I don't think you need to downgrade React Native itself, just the @babel/core and @babel/runtime.

@siderakis
Copy link

I've tried all the mentioned versions of @babel/core and @babel/runtime with no luck. In-between builds I ran react-native-clean-project to do a full clean. I also removed as many devDependencies as I could and only have a few in addition to those in the sample app.

@dennislky Did you get it working?

@NullPainter2
Copy link

NullPainter2 commented Sep 16, 2021

@siderakis @dennislky Metro depends on newer version of babel. Older version can be forced inside package.json this way:

  "resolutions": {
    "@babel/core": "7.12.17",
    "@babel/runtime": "7.12.18"
  },

Forcing this version worked for me.

BUT cleaning up yarn.lock made app work on newer version. (btw, I cleaned up yarn.lock before forcing older version of babel too.) I found it out by accident ... Babel is made of like million packages for some reason. So I cleaned up yarn.lock to avoid duplication of all those babel packages, so multiple minor version of all of babel packages are resolved to just the newest version which was inside file. Then. When I just out of curiosity removed "resolve" from package.json and deleted resolution to old version, newer babel version was working just fine.

Currently newer version which works for me is this:

@babel/core 7.15.15
@babel/runtime 7.12.18

@NullPainter2
Copy link

NullPainter2 commented Sep 16, 2021

Update. I just tried deleting yarn.lock and it worked, no need to revert to older babel at all. :) Of course I needed to reinstall packages and fix some unrelated stuff (packages I did not wanted to update) ... :D

@kolarus
Copy link

kolarus commented Nov 1, 2021

Still have the same issue even removing yarn.lock, downgrading babel does not seem to resolve this. Happens after upgrade 0.64.2-0.65.1

@steffen25
Copy link

Did someone find a solution to this problem? I also tried to downgrade babel etc. but still no luck.
Im experiencing the same error as OP.

node_modules/react-native-keyboard-aware-scroll-view/lib/KeyboardAwareHOC.js: #<WeakSet> could not be cloned.

I see OP opened an issue in the repository of this Keyboard library but unfortunately no activity.
APSL/react-native-keyboard-aware-scroll-view#481

@Rananjaya Are you still running into this issue if not Im curious to know what you did to solve it.

@dlajarretie
Copy link

dlajarretie commented Jan 10, 2022

I'm having the same issue as described in APSL/react-native-keyboard-aware-scroll-view#481, even when downgrading babel dependencies.

@steffen25 Did you find a solution ?

I'm encountering the issue when upgrading to RN 0.66.4. No problem with 0.63.

Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions github-actions bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jan 12, 2024
Copy link

This issue was closed because it has been stalled for 7 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Triage 🔍 Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

10 participants