Search code examples
javascriptnode.jsmeteorgalaxy

Cannot read properties of undefined (reading 'slice') when trying to run our meteor application in chrome only


All of the sudden on our Meteor sites (only in chrome), we get the following router error message from time to time:

enter image description here

If you click on where the error is in the console, it points to this line:

var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : processNextTick;

For some reason all of sudden this week, process.version is undefined (again only in chrome).. When we refresh the page, everything is fine. But this is causing issues for alot of our users as it keeps happening randomly.

I've read other articles online that say try setting process.version manually in a global.js, but this did not work for us. Some articles have also said to manually edit that node package to include the needed variable, but this wont work either, as our Galaxy site re-installs the node packages on every deploy, so our changes would just get wiped.

Does anyone know of a better way we can set this process.version variable so this stops happening? Or maybe a better solution overall?


Solution

  • For me, I solved the issue by using the node patch-package module to add the following line of code to the following 2 node package files:

    1. node_modules/meteor-node-stubs/node_modules/pbkdf2/browser.js:

      var process = require("process");

    2. node_modules/meteor-node-stubs/node_modules/readable-stream/lib/_stream_writable.js

      var process = require("process");

    Depending on where the error is being thrown on your project, it may be in a different node package file