alphagov / govuk-prototype-kit

Rapidly create HTML prototypes of GOV.UK services
https://prototype-kit.service.gov.uk
MIT License
301 stars 236 forks source link

Failure to read manage-prototype.css file in error server #2335

Closed BenSurgisonGDS closed 12 months ago

BenSurgisonGDS commented 1 year ago

After a migration the user was unable to start their prototype with a misleading error.

Description of the issue

After a migration and running the kit for the first time, the following error appeared in their terminal

Error: ENOENT: no such file or directory, open '/home/ben/projects/prototype-kits/companion-prototype-kit/.tmp/public/stylesheets/manage-prototype.css' at Object.openSync (node:fs:600:3) at Object.readFileSync (node:fs:468:35) at runErrorServer (/home/ben/WebstormProjects/govuk-prototype-kit/lib/errorServer.js:42:20) at Object.<anonymous> (/home/ben/WebstormProjects/govuk-prototype-kit/listen-on-port.js:46:5) at Module._compile (node:internal/modules/cjs/loader:1218:14) at Module._extensions..js (node:internal/modules/cjs/loader:1272:10) at Module.load (node:internal/modules/cjs/loader:1081:32) at Module._load (node:internal/modules/cjs/loader:922:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 { errno: -2, syscall: 'open', code: 'ENOENT', path: '/home/ben/projects/prototype-kits/companion-prototype-kit/.tmp/public/stylesheets/manage-prototype.css' }

Steps to reproduce the issue

Solution

By being defensive and making sure the /.tmp/public/stylesheets/manage-prototype.css file exists before attempting to read it within the error server, it will make it possible to see the real error even if the error page is not styled.