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

t.replace(...).replaceAll is not a function #884

Closed
MichalMoravik opened this issue Feb 25, 2024 · 2 comments · Fixed by #885
Closed

t.replace(...).replaceAll is not a function #884

MichalMoravik opened this issue Feb 25, 2024 · 2 comments · Fixed by #885
Labels
bug Something isn't working unconfirmed Needs triage.

Comments

@MichalMoravik
Copy link
Contributor

Description

Hi!

People using slightly older browsers trigger the following error in my Sentry:

t.replace(...).replaceAll is not a function

that's because replaceAll is kinda new function.

Would it be possible to change the usage of this in the project? It appears only at two places:

  1. .replaceAll('(.*)]', '(.*)');
    (the one that is relevant to my current error I assume)
  2. template = template.replaceAll('[[', '[').replaceAll(']]', ']');
    (have not seen error with this one yet but I think it might come if the first place gets changed and this not)

My users are hitting error boundary and cannot use the web at the moment.

Full Error Stack

{
message: t.replace(...).replaceAll is not a function, 
name: TypeError, 
stack: 
TypeError: t.replace(...).replaceAll is not a function
    at a (https://www.vasekvety.sk/_next/static/chunks/296-ae496176be3b700e.js:1:7719)
    at Object.e.matchesPathname (https://www.vasekvety.sk/_next/static/chunks/296-ae496176be3b700e.js:1:8149)
    at https://www.vasekvety.sk/_next/static/chunks/296-ae496176be3b700e.js:1:6444
    at Array.find (<anonymous>)
    at Object.e.getRoute (https://www.vasekvety.sk/_next/static/chunks/296-ae496176be3b700e.js:1:6388)
    at usePathname (https://www.vasekvety.sk/_next/static/chunks/296-ae496176be3b700e.js:1:2092)
// ... the rest is not relevant ...

Mandatory reproduction URL

Not needed really

Reproduction description

Steps to reproduce:

  • I don't think this is necessary; both the error and the docs mentioning replaceAll is a new function are descriptive enough

Expected behaviour

I expect that the templateToRegex function is run without any error at replaceAll() line

@MichalMoravik MichalMoravik added bug Something isn't working unconfirmed Needs triage. labels Feb 25, 2024
@MichalMoravik
Copy link
Contributor Author

I just created PR as well to help with this: #885

@MichalMoravik
Copy link
Contributor Author

Hi @amannn! Thanks for the quick reply in the PR.

So the last user who had problem was using Chrome 60.0.3112 (2017) on Windows 8.1.

Another user has Chrome 81.0.4044. This version is from April 2020 just 4 months before the replaceAll was added.

replaceAll is just too new in my opinion. Generally it started to be supported 2021 onwards and there is a lot of people in Slovakia (where we get most users from) who haven't updated their browser for 3 years (even longer).


Regarding the failing tests. I actually ran pnpm run test locally before pushing but I saw only the last couple of lines saying PASS so I thought all passed. Sorry for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed Needs triage.
Projects
None yet
1 participant