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

TypeError: Cannot read property 'match' of null #419

Closed
bkimminich opened this issue Nov 25, 2019 · 6 comments
Closed

TypeError: Cannot read property 'match' of null #419

bkimminich opened this issue Nov 25, 2019 · 6 comments

Comments

@bkimminich
Copy link
Contributor

bkimminich commented Nov 25, 2019

C:\Data\GitHub\juice-shop\node_modules\i18n\i18n.js:643
    if (extension && !filename.match(extensionRegex)) return false;
                               ^

TypeError: Cannot read property 'match' of null
    at guessLocaleFromFile (C:\Data\GitHub\juice-shop\node_modules\i18n\i18n.js:643:32)
    at FSWatcher.<anonymous> (C:\Data\GitHub\juice-shop\node_modules\i18n\i18n.js:166:32)
    at FSWatcher.emit (events.js:189:13)
    at FSEvent.FSWatcher._handle.onchange (internal/fs/watchers.js:131:12)

This happens when a string is queried that does not exist (yet) in the given locale. When logging filename in the function throwing the error, I get e.g. de_DE.json.tmp and next up null, whereas otherwise the function receives de_DE.json as I would always expect.

My config is

i18n.configure({
  locales: locales.map(locale => locale.key),
  directory: path.join(__dirname, '/i18n'),
  cookie: 'language',
  defaultLocale: 'en',
  autoReload: true
})
app.use(i18n.init)
@bkimminich
Copy link
Contributor Author

More precisely, this is the sequence of events when fs.watch triggers in my error case after adding a console.log(event + ' -> ' + filename) log statement:

rename -> de_DE.json.tmp
change -> null

bkimminich added a commit to juice-shop/juice-shop that referenced this issue Feb 11, 2020
@Tim-arts
Copy link

The issue is still present on the latest version. In my case it fails when using "autoReload" to "true".

@mashpie
Copy link
Owner

mashpie commented Feb 21, 2020

@TyrionGraphiste any more details to reproduce?

@Tim-arts
Copy link

Tim-arts commented Feb 22, 2020

Hi @mashpie , I've no clue about what is causing this issue, it seems the "filename" parameter is null in my case. Adding if (!filename) return false; before apparently solves the issue but it might not be a real and solid workaround.

@Tim-arts
Copy link

I didn't see it was fixed in the 0.8.5 version and the "Open" tag on this ticket led me to think I had the latest version. I was still on 0.8.4 version, passed to 0.8.5 and it's fixed. Sorry for this mistake!

@mashpie
Copy link
Owner

mashpie commented Feb 22, 2020

Ok, no worries glad to hear it‘s fixed.

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

3 participants