Adding and then removing a watch.json file breaks auto install/refresh

I added a watch.json file to try and optimize when my Node.js/express app refreshes and how hard (install vs restart). It wasn’t working as expected, so I removed the watch.json file entirely. Now the project never refreshes at all unless I open a terminal and run refresh manually :cry:.

I have a project with the following watch.json file:

{
  "install": {
    "include": [
      "^package\\.json$",
      "^\\.env$"
    ]
  },
  "restart": {
    "exclude": [ ],
    "include": [
      "server\\.js",
      "assets\\.js",
      "\\.json"
    ]
  },
  "throttle": 100
}

This project does not restart when I change server.js

Either I’m totally misunderstanding the watch.json file, or it would seem that there is a >50% chance that any given edit to it will just put your app into a bad state and you just have to wait for it to get forcibly rebooting :triumph:. And of course I can’t find a shred of official documentation for this thing.

Can anybody out there give me a clue?!

One reason I’ve been so confused is that watch.json does not affect auto-refresh in the preview panel/window (what you get by clicking the “show” button). So some things that I thought were not working (such as excludes), actually were working, I was just assessing them incorrectly (seeing if the preview panel refreshed as opposed to if the spinner showed up next to app status).

However, I still have the issue of putting my app in the bad state when editing watch.json. And I haven’t been able to get https://api.glitch.com/projects/{my-project-name}/stop?authorization={my-persistent-token} to work which I have seen referenced in other forum posts.

What are you having trouble with? What error message does the API give?

I get a 404 Not Found response, here’s an example using curl:

curl --location --request POST 'https://api.glitch.com/projects/code-haumana-p5js-hot-reload/stop?authorization={redacted-uuid}'

Try using the new API endpoint:

curl -X POST -H 'Authorization: {persistentToken}' 'https://api.glitch.com/v1/projects/{projectId}/stop'

It seems you already know how to get your token. However, for completeness, here is how to get your project ID and token (there are many ways to do it, but this is the one I use myself):

Go to the project editor and open your browsers console (not the one in the editor).

To get your token run:

application.persistentToken()

To get the projects ID run:

application.currentProjectId()
2 Likes