Skip to content

[bug]: potentially race condition #553

Open
@ShaunSHamilton

Description

@ShaunSHamilton

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    patchThis issue/PR results in a patch releasetype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions