question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

React-native bundler takes exponentially longer (eventually timing out) for very large js files.

See original GitHub issue

Is this a bug report?

Yes

Have you read the Contributing Guidelines?

Yes

Environment

Environment: OS: macOS High Sierra 10.13.2 Node: 6.3.1 Yarn: Not Found npm: 3.10.3 Watchman: 4.6.0 Xcode: Xcode 8.0 Build version 8A218a Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed) react: ^16.0.0-beta.5 => 16.0.0-beta.5 react-native: ^0.51.0 => 0.51.0

Steps to Reproduce

Steps to reproduce this can be found in the README in the following repo: https://github.com/ScottPierce/ReactNativeKotlinError

Expected Behavior

That the kotlin.js file from npm, or other large javascript files, could properly be bundled with react-native.

Actual Behavior

Bundling kotlin.js freezes:

Bundlingindex.js[development, non-minified] ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░ 99.6% (476/477)

And eventually times out:

error: bundling failed: Error: TimeoutError: transforming /Users/spierce7/workspace/KotlinReactNative/kotlin.js took longer than 601 seconds.

    at _transform.then.catch.error (/Users/spierce7/workspace/KotlinReactNative/node_modules/metro-bundler/src/JSTransformer/index.js:183:28)
    at process._tickCallback (internal/process/next_tick.js:103:7)

I removed most of the content from the javascript file, and things bundled just fine. I slowly added more and more content back to the kotlin.js file, and bundling times rose exponentially. Here are some rough estimates:

At 15k lines, bundling the file took ~17 seconds.
At 18k lines, bundling the file took ~30 seconds.
At 23k lines, bundling the file took ~60 seconds.
The actual file is 37k+ lines, and times out when bundling

Reproducible Demo

https://github.com/ScottPierce/ReactNativeKotlinError

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ScottPiercecommented, Jan 9, 2018

After further research, the problem seems to come from the large size of the kotlin.js file.

Is there a way I could either allocate more memory to the process, or perhaps I could somehow provide the kotlin.js file myself for develop builds? In production builds, dead code elimination can be run, and the resulting kotlin.js will be much smaller. I’d also need to ensure I could debug with this approach as well.

@jeffreymendez1993 Because it’s a fantastic high level language that has positioned itself in a good place for cross platform mobile development. i.e. When Kotlin-native is released later this year, it would be a fantastic way to write background tasks that run on separate threads and don’t lag the js thread, and can run on android (jvm), and ios (native). Also I’ve already written a lot of code in Kotlin, and being able to port that over and use that in react-native would be a huge win.

0reactions
amalChandrancommented, Apr 2, 2018

@ScottPierce Is this issue resolved on v0.53.0 ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

React-native bundler takes exponentially longer (eventually ...
React-native bundler takes exponentially longer (eventually timing out) for very large js files. facebook/react-native#17485.
Read more >
Drastically Faster Bundling in React Native | by Evan Bacon
The files in our app can be divided into two logical groups; application code, and Node modules. This distinction is important for a...
Read more >
react native downloading javascript bundle 100% stuck
What finally worked was restarting the React Native Debugger that I had on ... The JS bundle would load to 100%, but then...
Read more >
Firebase JavaScript SDK Release Notes - Google
The SDK no longer causes React Native to log a warning about deprecation of AsyncStorage ... Otherwise the pending timeout may prevent Node.js...
Read more >
Improving JavaScript Bundle Performance With Code-Splitting
Projects built using JavaScript-based frameworks often ship large bundles of JavaScript that take time to download, parse and execute, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found