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

(node:11916) UnhandledPromiseRejectionWarning: TypeError: route.match is not a function #286

Closed
2M4U opened this issue Apr 8, 2021 · 4 comments

Comments

@2M4U
Copy link

2M4U commented Apr 8, 2021

(node:11916) UnhandledPromiseRejectionWarning: TypeError: route.match is not a function
        at processRoute (C:\Users\CG\Desktop\Github\VideoBox\node_modules\reload\lib\reload.js:220:35)
        at C:\Users\CG\Desktop\Github\VideoBox\node_modules\reload\lib\reload.js:25:32
        at new Promise (<anonymous>)
        at reload (C:\Users\CG\Desktop\Github\VideoBox\node_modules\reload\lib\reload.js:13:10)
        at module.exports (C:\Users\CG\Desktop\Github\VideoBox\node_modules\reload\index.js:4:10)
        at Object.<anonymous> (C:\Users\CG\Desktop\Github\VideoBox\index.js:37:1)
        at Module._compile (internal/modules/cjs/loader.js:1063:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
        at Module.load (internal/modules/cjs/loader.js:928:32)
        at Function.Module._load (internal/modules/cjs/loader.js:769:14)

Code in question:

   function processRoute (route) {
      // If reload.js is found in the route option strip it. We will concat it for user to ensure no case errors or order problems.
      const reloadJsMatch = route.match(/reload\.js/i)
      if (reloadJsMatch) {
        route = route.split(reloadJsMatch)[0]
      }
@alallier
Copy link
Owner

alallier commented Apr 8, 2021

Can you show me how you are calling reload? My guess is a route is being passed that is not of type string. Oddly enough I don't have a type check for that option or unit test it seems.

Mostly likely a bug, but need to confirm on my end. Your confirmation would also be good evidence.

@2M4U
Copy link
Author

2M4U commented Apr 8, 2021

I will do some more testing on this, and update you on my progress.
I am currently unable to provide how I'm calling it at this moment in time, but as stated above, I will inform you of more testing.

You could add

 if (route !== typeof 'string') return;

in the code provided initially which then would in my case trigger line 39

  return reject(new Error('Lack of/invalid arguments provided to reload'))

More update:
I've noticed that if you don't require 'reload/reload.js' inside your webpage it would then trigger this issue above on this comment with the code I implemented, and same without it.
As my understanding of this package it seems it would be required for every single webpage (?), I maybe wrong on this assumption.
Would it be able to make the package not be required for every single page? (if the above statement applies.)

@alallier
Copy link
Owner

alallier commented Apr 8, 2021

The reload/reload.js script tag needs to be on every HTML page if you want auto reloading on that page.

You can use templating or server side injection to put it on every page.

@alallier
Copy link
Owner

Another option is to server side inject the reload script into every page. Which some applications layers/frameworks have successfully done like Roosevelt

Anyways we have an option issue for this currently #12. Therefore I'm going to close this issue. We can pickup the conversation over there

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

No branches or pull requests

2 participants