#keys is not a function - obscure browsers

1 messages · Page 1 of 1 (latest)

jovial solar
#

We're using [email protected] (6.4.0 confirmed broken too).

When opening the app, we receive an error (unfortunately don't have source maps on Sentry):
r of t.keys is not a function. (In 'r of t.keys()', 'r of t.keys' is undefined)

Happening on:

  • Messenger's in-app browser on iOS

Works on:

  • iOS Safari
  • Chrome iOS

Thankfully comments aren't minified, so the Sentry error is attached.

Any ideas? Some polyfill needed? What are we calling in React Router's source code that is causing this?

rancid spade
#

It seems like an issue with for (let x of thing) where thing is a Set or Map, both of which we have in the source code. Are you able to transpile that according to a minimum browser set in your build?

jovial solar
#

Thanks. I'm not sure what you mean by that 😢

I just figured out it is working on localhost so I guess it is maybe related to our minification?

slate horizon
#

What version of iOS is it broken on? Only place I can find a similar pattern in the source is the useSearchParams hook, but everything here should be supported in iOS >= 10

export function useSearchParams(
  defaultInit?: URLSearchParamsInit
): [URLSearchParams, SetURLSearchParams] {
  let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));

  let location = useLocation();
  let searchParams = React.useMemo(() => {
    let searchParams = createSearchParams(location.search);

    for (let key of defaultSearchParamsRef.current.keys()) {
      if (!searchParams.has(key)) {
        defaultSearchParamsRef.current.getAll(key).forEach((value) => {
          searchParams.append(key, value);
        });
      }
    }

    return searchParams;
  }, [location.search]);
jovial solar
#

Latest iOS version :/ Android experiencing this too.

#

Facebook Messenger's in app browser and "Apple Mail" marked in Sentry too, we haven't reproduced this on other browsers/devices

jovial solar
#

I'm so lost here, not sure what the next step for me would be.

I've found the broken code in the minified bundle and it is 100% in React Router's source code.

#

It is also happening in our Expo Webview

jovial solar
#

I'm thinking if this might be related to React Native Webview

#

We've tried changing minifiers and that doesn't do anything

jolly pawn
#

@jovial solar can you post the broken code in the minified bundle? it seems like the JS engine is parsing the JS weird. r of t.keys is not a single token but it seems to think it is