Skip to content
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

[RN new architecture] Invalid non-string URL" for scriptURL - Falling back to localhost #1486

Open
neeteshraj opened this issue Jun 19, 2024 · 13 comments

Comments

@neeteshraj
Copy link

Describe the bug

I am getting this error in development. getHost: "Invalid non-string URL" for scriptURL - Falling back to localhost.

Steps to reproduce. Create RN app. I am in ios with new architecture enabled. This is the reactoronConfig.ts file import Reactotron, {openInEditor, ReactotronReactNative} from 'reactotron-react-native';
import mmkvPlugin from 'reactotron-react-native-mmkv';
import {reactotronRedux} from 'reactotron-redux';
import {storage} from './store';

import config from '../app.json';

Reactotron.configure({
name: config.name,
})
.useReactNative({
networking: {
ignoreUrls: /symbolicate/,
},
editor: false,
errors: {veto: stackFrame => false},
overlay: false,
})
.use(openInEditor())
.use(mmkvPlugin({storage}))
.use(reactotronRedux())
.connect();

export default Reactotron;
and this is the index.js /**

import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import 'react-native-gesture-handler';

if (DEV) {
import('@/reactotron.config');
}
AppRegistry.registerComponent(appName, () => App);

Reactotron version

5.1.7

@maksim-romanov
Copy link

same issue

@neeteshraj
Copy link
Author

@maksim-romanov did you find any solutions?

@adamsinnott
Copy link

I got the same issue running this recipe but with npm instead of bun
https://ignitecookbook.com/docs/recipes/Authentication/

Using Ignite 9.7.1
npx ignite-cli@latest new AuthRecipe --workflow=cng --remove-demo --git --install-deps --packager=npm
✅ What bundle identifier? · com.authrecipe
✅ Where do you want to start your project? · projects/AuthRecipe
✅ ❗EXPERIMENTAL❗Would you like to enable the New Architecture? (y/N) · Yes

After installing I ran:
npm run ios

This then gives the following failure:

› Installing on iPhone 15 Pro Max
› Opening on iPhone 15 Pro Max (com.authrecipe)
› Opening exp+authrecipe://expo-development-client/?url=http%3A%2F%2F192.168.1.182%3A8081 on iPhone 15 Pro Max

› Logs for your project will appear below. Press Ctrl+C to exit.
iOS Bundled 20212ms node_modules/expo/AppEntry.js (1698 modules)
 (NOBRIDGE) LOG  Bridgeless mode is enabled
 (NOBRIDGE) WARN  getHost: "Invalid non-string URL" for scriptURL - Falling back to localhost
iOS Bundled 116ms node_modules/expo/AppEntry.js (1 module)
 (NOBRIDGE) LOG  Bridgeless mode is enabled
 (NOBRIDGE) WARN  getHost: "Invalid non-string URL" for scriptURL - Falling back to localhost

@adamsinnott
Copy link

adamsinnott commented Jul 5, 2024

I have noticed that in node_modules/reactotron-react-native/src/reactotron-react-native.ts there is this snippet.

const getHost = (defaultHost = "localhost") => {
  try {
    // RN Reference: https://github.com/facebook/react-native/blob/main/packages/react-native/src/private/specs/modules/NativeSourceCode.js
    const scriptURL = NativeModules?.SourceCode?.getConstants().scriptURL
    if (typeof scriptURL !== "string") throw new Error("Invalid non-string URL")

    return getHostFromUrl(scriptURL)
  } catch (error) {
    console.warn(`getHost: "${error.message}" for scriptURL - Falling back to ${defaultHost}`)
    return defaultHost
  }
}

When you inspect it, you can see that NativeModules is an empty object {}, thus no SourceCode and no getConstants function. It is this section that is causing the error to be thrown.

Not sure I have the right file but the React Native code that is referenced was last changed 6 months ago and it looks to use new architecture.

I'm going to try with turning new architecture off and see how far I get.

@saintyusuf
Copy link

is there any update about this issue?

@saintyusuf
Copy link

is there any update about this issue?

i solved it very quickly.

i was installing pods with RCT_NEW_ARCH_ENABLED=1 pod install, and getting that error when app starts everytime.

i installed pods without new arch and problem solved. so, just do pod install in ios folder and try to start app just like that.

@RoyRao2333
Copy link

Is there any solutions with the new arch enabled?

@adamsinnott
Copy link

I tried using this react native url polyfill to see if that worked but it didn't (or I didn't implement it correctly). Moving to the old architecture worked though. Not a long term possibility though.

@morganick
Copy link
Contributor

Hey folks, looks like the interface we were using here no longer exists in new arch. I was hoping this was a simple fix I could do while we were at Chain React Conf.

Looks like it will be more involved. Stay tuned.

@denysoleksiienko
Copy link

any update for the new arch?

Copy link
Contributor

@mark and I went over this last week. I got him up to speed with my research on the topic. Unfortunately, I haven't had a spare moment to work on it.

We feel the same pain as we prepare our applications for the new arch.

@markrickert
Copy link
Member

lol Wrong Mark, @morganick :P

Thanks for the trace @adamsinnott. We're going to have to figure out where this variable lives in the new architecture. I'm on a deadline crunch right now but can probably look into this after.

For now, i've silenced the warning with:

if (__DEV__) {
  LogBox.ignoreLogs([
    'getHost: "Invalid non-string URL" for scriptURL - Falling back to localhost',
  ])
}

@jamonholmgren jamonholmgren changed the title Invalid non-string URL" for scriptURL - Falling back to localhost [RN new architecture] Invalid non-string URL" for scriptURL - Falling back to localhost Aug 26, 2024
@mym0404
Copy link

mym0404 commented Sep 11, 2024

Workaround for ignoring warning.

  const _ = console.warn;
  console.warn = () => {};
  LogBox.ignoreLogs(['Invalid non-string URL']);
  const Reactotron = require('reactotron-react-native').default;
  console.warn = _;

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

No branches or pull requests

9 participants