smollweide / node-mock-server

File based Node REST API mock server
MIT License
255 stars 65 forks source link

UI freezes when refreshing after removing endpoint from filesystem #156

Open sander-bol opened 4 years ago

sander-bol commented 4 years ago

I just ran into an issue where the Mock Server UI became unusable. Took me a few minutes to figure out what was going wrong. While the UI was open, a git operation had altered the filesystem and removed an endpoint.

Acceptance criterion Given the Mock Server UI is loaded with a URL fragment And that URL fragment no longer corresponds to an endpoint on the file system When the UI loads Then I do not expect the gray 'modal' overlay to appear, without any content being loaded, effectively blocking the UI.

Steps to reproduce:

  1. Define an endpoint (GET /hello, for example).
  2. Open the dialog to modify that endpoint (note the URL now contains a fragment identifier for that endpoint)
  3. While the dialog is still open, delete the /hello endpoint from the filesystem.
  4. Refresh the page.

The endpoint listing will be visible; however, the modal overlay blocks all UI interactions. No actual modal dialog is present, though.

Suggested fix If the UI cannot load the data for the endpoint specified in the fragment, display an error instead of the edit dialog. Alternatively (possibly simpler), if the data cannot be loaded, do not try to show the edit dialog.