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.

Crash in production React app

See original GitHub issue

Hello @tmcw !

We’re currently using v4.3.0 (also tested in v4.2.0) of togeojson.

When calling tj.kml with this kml file in our React v16.12.0 production app, based on create-react-app, We get the following console error:

TypeError: u is not a function
    at kml.js:296
    at l (runtime.js:63)
    at Generator._invoke (runtime.js:293)
    at Generator.next (runtime.js:118)
    at Function.from (<anonymous>)
    at e.kml (kml.js:316)
    at Object.KML (index.es.js:32035)
    at setTimeout.format (index.es.js:32063)
    at index.es.js:32225

This error does not occur when running locally in development, and when using your online tool, again there is no problems. Therefore we think the issue lies in the minified build.

Just to clarify, KML files without the StyleMap element do not have this problem.

I’d appreciate any assistance you could provide 😃

Using as below:

  import * as toGeoJSON from '@tmcw/togeojson';

  ...

  const dom = (new DOMParser()).parseFromString(kmlString, 'text/xml');
  const parsedGeojson = toGeoJSON.kml(dom);

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12

github_iconTop GitHub Comments

1reaction
tmcwcommented, Feb 25, 2022

Great, good to have an example of the workaround. As far as this issue, it’s upstream, in Terser. There’s no way for this project to avoid the bug in Terser.

1reaction
OllieRushtoncommented, Jan 11, 2021

@tmcw , so we’ve managed to get around the issue, but still not 100% sure what the cause was.

We have a map module which relied on @tmcw/togeojson as a peer dependency, and we installed both the map module and your package as hard dependencies in our create-react-app.

During the build (where we use the default build settings of create-react-app), for whatever reason, the uglified code was using the same variable for the nodeVal function and the hash variable in kmlGen of your source code.

FIX

We changed @tmcw/togeojson from a peer dependency to a hard dependency of our map module.

This changed the structure of the dependency graph during webpacks build process, causing the uglified code to be slightly different, and removing the variable name scope issue laid out above.

Thanks again @tmcw for all the help!

Read more comments on GitHub >

github_iconTop Results From Across the Web

React App crashes when running the production build
My React app was crashing on only one specific screen on the production build, but not in the dev environment.
Read more >
[IOS] Random app crash on production build #2327 - GitHub
I'm hosting my shared values in react context, so that these values can later be accessed by various components on the screen. The...
Read more >
Eight Practices in React That Will Crash Your App in the Future
If you're currently building an application using react or thinking of using react for upcoming projects, then this tutorial is for you.
Read more >
8 Practices In React That Will Crash Your App In The Future
If you're currently building an application using react or thinking of using react for upcoming projects, then this tutorial is for you.
Read more >
Error Boundaries - React
These errors were always caused by an earlier error in the application code, ... and display a fallback UI instead of the component...
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