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.

Broken production with Metro bundler (ReferenceError)

See original GitHub issue

Hi 👋

On the latest version, a modification (somewhere around here) broke the metro bundler in production mode (and possibly other production apps? It’s not tied to minification, but I didn’t tried on other bundlers).

urql version: 1.9.7

Steps to reproduce

  1. Create a new React Native project
  2. Add urql@1.9.7, wrap your app in a Provider with an urql client
  3. Build your app for production
  4. Starts your app. It will crash at client init.

Expected behavior

No JS ReferenceError.

Actual behavior

For some reason, the variable is not declared.

Debugging

In order to spot the issue, I created a server to serve the unminified production bundle to my debug application. Create a file at project root:

// server.js

const express = require("express");
const app = express();

app.use((req, res, next) => {
  console.log(req.url);
  res.setHeader("Content-Type", "application/javascript");
  next();
});

app.use("/", express.static("."));
app.use("/assets", express.static("."));
app.get("/status", (_req, res) => {
  res.send("packager-status:running");
});

app.listen(8081, () => {
  console.log("Serving directory as localhost:8081");
});

Build a bundle with:

yarn react-native bundle --entry-file index.js --bundle-output index.bundle --platform ios --dev false --minify false

Then run the server.js file to fake metro bundler, it will be easier to debug.

Fix

The missing declaration is f:

Screenshot 2020-04-22 at 13 57 36

If I add it manually to the bundle, it works:

Screenshot 2020-04-22 at 13 57 58

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
zoontekcommented, Apr 22, 2020

Thanks, that was fast!

1reaction
kittencommented, Apr 22, 2020

This should be released in @urql/core@1.11.5, so a quick yarn upgrade @urql/core should fix the issue 👍 https://github.com/FormidableLabs/urql/releases/tag/%40urql%2Fcore%401.11.5

Read more comments on GitHub >

github_iconTop Results From Across the Web

SHA-1 for file ... is not computed when using resolver ... - GitHub
I solved this issue by using yarn start instead of starting project with react-native start (it uses npm start). I have been adding...
Read more >
Metro Bundler fails while trying to resolve module `immer ...
So I tried to manually remove node_modules/ and reinstall packages with yarn , restart the Expo server, doing all this after restarting my ......
Read more >
Using Hermes in React Native - LogRocket Blog
Here is a list of break-in changes for Hemes in React Native 0.70: More work on performance; React Native Hermes integration: going forward,...
Read more >
* a module failed to load due to an error and `appregistry ...
This can happen if: Metro (the local dev server) is run from the wrong folder. Check if Metro is running, stop it and...
Read more >
Metro bundler - Expo Documentation
const { getDefaultConfig } = require('expo/metro-config'); const config = getDefaultConfig(__dirname); // Remove all console logs in production... config.
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