freeCodeCamp / freeCodeCampOS

Test repo for external freeCodeCamp courses

Home Page:https://opensource.freecodecamp.org/freeCodeCampOS/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[bug]: potentially race condition

ShaunSHamilton opened this issue Β· comments

Sometimes, specifically during development, an error is thrown by the config/state.json reader indicating the content is not valid JSON:

🟒 DEBUG:  2024-04-03 15:14:00 Watcher: change - /back-end-development-and-apis/curriculum/locales/english/build-a-timestamp-microservice.md
πŸ”΄ ERROR:  2024-04-03 15:14:34 SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at getState (file:///back-end-development-and-apis/node_modules/@freecodecamp/freecodecamp-os/.freeCodeCamp/tooling/env.js:43:24)
    at async runLesson (file:///back-end-development-and-apis/node_modules/@freecodecamp/freecodecamp-os/.freeCodeCamp/tooling/lesson.js:30:41)
    at async FSWatcher.<anonymous> (file:///back-end-development-and-apis/node_modules/@freecodecamp/freecodecamp-os/.freeCodeCamp/tooling/hot-reload.js:58:7)
πŸ”΄ ERROR:  2024-04-03 15:14:34 SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at getState (file:///back-end-development-and-apis/node_modules/@freecodecamp/freecodecamp-os/.freeCodeCamp/tooling/env.js:43:24)
    at async Object.getLesson (file:///back-end-development-and-apis/node_modules/@freecodecamp/freecodecamp-os/.freeCodeCamp/plugin/index.js:115:24)
    at async runLesson (file:///back-end-development-and-apis/node_modules/@freecodecamp/freecodecamp-os/.freeCodeCamp/tooling/lesson.js:33:7)
    at async FSWatcher.<anonymous> (file:///back-end-development-and-apis/node_modules/@freecodecamp/freecodecamp-os/.freeCodeCamp/tooling/hot-reload.js:58:7)
🟒 DEBUG:  2024-04-03 15:14:34 Watcher: change - /back-end-development-and-apis/.logs/.terminal_out.log
🟒 DEBUG:  2024-04-03 15:14:34 Watcher: change - /back-end-development-and-apis/.logs/.history_cwd.log

Looking at the file, it appears intact. So, the assumption is whilst content is being written to state.json, the file is also being read.