Default router (wouter) stops working when project sleeps

For some reason, the template implementation of wouter stops working when the project goes to sleep. My project renders a blank page until I load up the editor again, at which point it works as intended for a few hours.

Glitch support had this to say:

It looks like your routing code isn’t working once the editor goes to sleep and the project switches to a Static Site. A little Googling suggests that these normal routers don’t work with static sites and suggest using client side routing or hash routing.

However, wouter claims that it does client-side routing by default. Has anyone run into anything similar?

Project: https://dicebox.glitch.me

Router Code:

<Switch>
    <Route path="/:game">{(params) => DiceBox(params.game)()}</Route>
    <Route path="*">
      {(params) => DiceBox('d20')()}
    </Route>
</Switch>

Main Loadpoint:

<Router>
      <main role="main" className="wrapper">
        <div className="content">
          {/* Router specifies which component to insert here as the main content */}
          <PageRouter />
        </div>
      </main>
</Router>

from the sleeping project:

index-004bef60.js:49 Uncaught TypeError: M1 is not a constructor
at index-004bef60.js:49:17429

something’s going wrong with the vite build, M1, which I believe is some mersenne twister library, is being compiled into essentially {default: (some object)}, which isn’t a function, so you the new M1 is throwing an error

some googling later: could you try

import {default as MersenneTwister} from "mersenne-twister";

and somehow test the built version…

I’ve changed the import for the package and will see how it affects it once it’s gone back to sleep.

alright looking good

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.