Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

electron-settings/package.json: Unexpected end of JSON input #138

Open
linonetwo opened this issue Oct 31, 2020 · 4 comments
Open

electron-settings/package.json: Unexpected end of JSON input #138

linonetwo opened this issue Oct 31, 2020 · 4 comments

Comments

@linonetwo
Copy link

SyntaxError: Error parsing /Users/linonetwo/Desktop/repo/TiddlyGit-Desktop/dist/mac/TiddlyGit.app/Contents/Resources/app.asar/node_modules/electron-settings/package.json: Unexpected end of JSON input

Uncaught Exception:
SyntaxError: Error parsing /Users/linonetwo/Desktop/repo/TiddlyGit-Desktop/dist/mac/TiddlyGit.app/Contents/Resources/app.asar/node_modules/electron-settings/package.json: Unexpected end of JSON input
    at parse (<anonymous>)
    at readPackage (internal/modules/cjs/loader.js:261:20)
    at resolveExports (internal/modules/cjs/loader.js:436:15)
    at Function.Module._findPath (internal/modules/cjs/loader.js:479:31)
    at Module._resolveFilename (internal/modules/cjs/loader.js:874:27)
    at Function.n._resolveFilename (electron/js2c/browser_init.js:257:1128)
    at Module._load (internal/modules/cjs/loader.js:732:27)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12745)
    at Module.require (internal/modules/cjs/loader.js:959:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/linonetwo/Desktop/repo/TiddlyGit-Desktop/dist/mac/TiddlyGit.app/Contents/Resources/app.asar/build/electron.js:6:18)
    at Module._compile (internal/modules/cjs/loader.js:1078:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1108:10)
    at Module.load (internal/modules/cjs/loader.js:935:32)
    at Module._load (internal/modules/cjs/loader.js:776:14)
    at Function.f._load (electron/js2c/asar_bundle.js:5:12745)
@linonetwo
Copy link
Author

This is similar to desktop/dugite#414

@FoonkG
Copy link

FoonkG commented Nov 14, 2020

Same issue here

@theArina
Copy link

Not the same case, but i get SyntaxError: Unexpected end of JSON input when the settings file is empty. It's not exactly an issue, cause json files shouldn't be empty, but i would suggest to the developer adding emptiness check just in case.

@WholeMilk
Copy link

I also ran into this issue, after digging into it a bit, this is partially due to how the set()/setSync() are designed.
Both of these "write" functions loads existing settings from disk first and perform a partial update by path with the new data, because of this, when the settings data file on disk has invalid JSON format, the loading/parsing fails and thus fails the write function call.
I can think of two things to help solve this:

  1. Better documentation on the set/partial-update functions, make it clear when using those functions, the settings file cannot be invalid JSON structure. I think many users that do not care about partial write are surprised that a seemingly write action is dependent on preexisting data being valid.
  2. Expose/export saveSettings()/saveSettingsSync() as a simpler pure/no-side-effect write counter part of set()/setSync() regardless of preexisting data and contrast their usage differences in doc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants