ChatGPTClaudeGrok / X / CursorGemini

DeepSeek Harness BOM Crash: Unexpected token in package.json

TroubleshootingPublished 2026-11-03Author: DeepSeek Plugin Market
DeepSeek HarnessUTF-8 BOMUnexpected tokenprofile manifeststartup crashEF BB BF
DeepSeek Harness crashes on Windows with Unexpected token: profiles/<name>/package.json starts with a UTF-8 BOM that JSON.parse never strips. Remove it.

DeepSeek Harness (DSH) crashes at startup on Windows with Unexpected token '', and the "recover and restart" button in the crash dialog crashes again — the most valuable first step for this failure is not reinstalling, it is looking at the first 3 bytes of the profile manifest. Read as UTF-8, readFileSync(path, 'utf8') keeps the BOM as an ordinary character at the start of the file, and the subsequent JSON.parse(raw) fails on that first character. A healthy profiles/<name>/package.json starts with 7B 0A 20 (left brace, newline, two spaces); with a BOM it starts with EF BB BF 7B. That is the whole test: are the first 3 bytes EF BB BF (#11731).

One-step test: read the first 3 bytes before reinstalling

The decisive signal: EF BB BF means a BOM, 7B 0A 20 means it is fine, and the two openings lead to completely different investigations. One command per platform.

  1. Windows (PowerShell): read the first 3 bytes.
powershell
$p = "$env:USERPROFILE\.dsh\profiles\desktop\package.json"
[BitConverter]::ToString([IO.File]::ReadAllBytes($p)[0..2])
#   expect 7B-0A-20; EF-BB-BF means a BOM
  1. macOS / Linux: use hexdump.
bash
hexdump -C ~/.dsh/profiles/desktop/package.json | head -1
#   expect the line to start with 7b 0a 20; ef bb bf means a BOM
  1. Cross-check with the file size. In the thread a healthy manifest is 1108 bytes and the corrupted backup is 950 bytes — but do not use size alone as a criterion, because the content itself changes. It only helps answer "is this the same file".

  2. Confirm the exact error text in the crash log. Expected: Unexpected token '' with the invisible character right after it being the BOM. If the error points at some other token (a } or a digit), this is not the BOM case and you should investigate JSON syntax instead.

Why a BOM makes startup fail outright

Short answer: the read side does not strip the BOM and calls JSON.parse directly, turning an optional tolerance into a fatal failure. A read-only review of master ce7073d5 pinpointed two locations.

  1. packages/boot/app-boot/src/profile.ts:552: readFileSync(path, 'utf8') reads as UTF-8, so the BOM comes back as part of the content.
  2. The same file at :557: JSON.parse(raw) parses directly, with no trimStart and no BOM stripping in between.

Per RFC 8259 §8.1: writers MUST NOT add a BOM, parsers MAY ignore it. Here the write side violated the rule and the read side turned "may ignore" into "crash on sight". So this is not a plugin problem and not a Node version problem — any tool that writes a BOM can trigger it.

Repair: strip the BOM and rewrite as UTF-8 without one

Short answer: remove the leading character, write back as UTF-8 without a BOM, and the first three bytes return to 7B 0A 20 so DSH starts. PowerShell commands from the community, tested by the reporter.

  1. Copy the original file outside the workspace first, so you can roll back if the edit goes wrong.

  2. Read the full text and strip the leading BOM.

powershell
$p = "$env:USERPROFILE\.dsh\profiles\desktop\package.json"
$t = [IO.File]::ReadAllText($p).TrimStart([char]0xFEFF)
  1. Write back with UTF-8 encoding and no BOM.
powershell
[IO.File]::WriteAllText($p, $t, (New-Object System.Text.UTF8Encoding($false)))
  1. Verify the bytes immediately.
powershell
[BitConverter]::ToString([IO.File]::ReadAllBytes($p)[0..2])
#   expect 7B-0A-20
  1. Start DSH. Expected: no more Unexpected token, and the UI opens normally. After the reporter ran these commands the machine recovered, with the manifest at 1108 B and the first three bytes at 7B 0A 20.

Two cautions: do not "just save" with PowerShell 5.1's default Out-File / Set-Content, since they are a common source of BOMs; and do not use an editor's "Save as UTF-8 with BOM". What you want is UTF-8 without a BOM.

Correcting a misread: the recovery flow does not rewrite the manifest, but it still offers no way out

Short answer: the recovery restart in the crash dialog does not corrupt the manifest again, but it is equally helpless against an unparseable manifest; the original claim that "recovery rewrites it" was corrected by the responder and retracted by the reporter. The source paths back this up.

  1. packages/boot/app-boot/src/profile-sanitize.ts:19 — the first step reads the same manifest.
  2. The parse failure throws before renameSync at :27, so execution never reaches the write step.
  3. packages/boot/app-boot/README.md:71 states Invalid profile JSON fails before mutation, matching the source.

So the causal chain "recovery rewrites and corrupts it" does not hold; the original thread put it too strongly and the reporter explicitly retracted it. But the real gap is more worth remembering: this recovery path reads the same broken file and throws on failure. It does not quarantine the bad file, does not roll back to the last good backup, and has no command-line entry point. The UI already has copy for "recovery failed", which shows this is expected — yet after the failure the user has nothing, and must edit bytes with external tools exactly as the reporter did.

One more detail is easy to misread: the reporter saw cordis.patch.yml.bak-1793378185239, which proves the manifest was parseable at that moment (the backup succeeded). So "I clicked recover 9 times and it crashed each time" only proves recovery cannot save you; it does not prove recovery corrupted the file (#11731).

Who wrote the BOM: DSH does not, so the source is outside DSH

Short answer: DSH's own writeProfileManifest does not write a BOM, and only one piece of code deliberately writes one, unrelated to profiles, so the source is an external editor, PowerShell 5.1, or manual handling. The evidence.

  1. The write side is clean. writeProfileManifest at profile.ts:569-571 is JSON.stringify(..., 2) + '\n', with no BOM.
  2. A repo-wide search hits exactly one deliberate BOM write. Searching packages and apps for FEFF|ufeff|utf8-sig, the only active BOM write is packages/util/native-command/src/file-applications-windows.ts:268 (used for Windows scripts); every other hit either strips or rejects a BOM before parsing. A full search of the 182MB published package found 30 hits, all inside yaml / ajv / yaml-ast / eventsource / devtools.
  3. A control case shows writes do not always add one. The same day at 12:41 the app rewrote the manifest itself (1108 bytes), the first three bytes were 7B 0A 20, and there were zero crashes over the following 21 hours.
  4. One point in the timeline remains unresolved: at 00:26:46 the manifest parsed; at 00:27:41 and 00:27:46 the renderer and host each crashed once; at 00:31:03 the opening bytes were ef bb bf again. For that four-minute window the reporter marked the source as undetermined, providing only the bytes and timestamps without asserting a cause.

The right stance while debugging: fix the bytes first so the machine starts, then record "who wrote it" as a separate question. Do not stay stuck in an unbootable state waiting for a provenance conclusion.

The cost of the recovery button, and where the real fix belongs

Short answer: "disable third-party plugins" in the crash dialog cuts bundles from 8 down to 2, trading a larger loss for one restart; the real fixes are read-side tolerance, recovery-side quarantine, and an entry point that does not depend on the GUI. The thread's suggestions, in priority order.

  1. Stop the bleeding on the read side (P0): route all config reads through one function that strips a BOM before JSON.parse, covering the UTF-16 BOM as well.
  2. Add recovery fallback (P0): quarantine a bad file as .bad-<ts>, restore from last-known-good, validate with the same loader before starting, and add crash-loop detection plus a safe mode.
  3. Fix the write-side root cause (P1): find the path that writes a BOM, switch to atomic writes (temp file plus rename), and read back to verify after writing.
  4. Set user expectations: the recovery button is not an all-purpose restart. It has no way out when the manifest cannot be parsed, and pressing it may also change your plugins configuration, so think before clicking.
  5. The reporter's addition: provide an entry point that does not depend on the GUI (a launch flag or a safe mode) so someone who cannot start the app can reset the manifest and disable plugins from inside it.

Things to keep in mind while debugging

For startup crashes, do the byte-level test before any version-level guessing; it saves a lot of reinstalling. Six points.

  1. The first 3 bytes outrank everything: EF BB BF is a BOM, 7B 0A 20 is healthy.
  2. Never "save as" with a default encoding: PowerShell 5.1's Out-File / Set-Content and an editor's UTF-8 with BOM both reintroduce the BOM.
  3. Verify the bytes after the repair, not just "it starts now" — the next write may bring the BOM back.
  4. The recovery button does not rewrite the manifest, and it also cannot rescue an unparseable one; do not interpret two crashes as "recovery made it worse".
  5. A change in file size is not a criterion; it only cross-checks against bytes and timestamps.
  6. If it still crashes after the BOM fix, change direction: post the exact error text with the first 8 bytes. If the first three bytes are already clean, you are looking at ordinary JSON syntax or a truncated file.

Source: Discussion #11731.

ChatGPTClaudeGrok / X / CursorGemini

FAQ

DeepSeek Harness Windows crash: is a BOM the cause?

In DeepSeek Harness, this is very likely a UTF-8 BOM at the start of the file. Reading with readFileSync(path, 'utf8') keeps the BOM as an ordinary character, and the following JSON.parse then fails on the very first character with Unexpected token. Hex-dump the first 3 bytes: EF BB BF confirms a BOM.

How do I check DeepSeek Harness package.json for a BOM?

In DeepSeek Harness, look at the first 3 bytes. Valid JSON starts with 7B 0A 20 (left brace, newline, two spaces), while a BOM file starts with EF BB BF 7B. On Windows you can read the byte array in PowerShell and convert it to hex; on macOS and Linux, hexdump or xxd the first 3 bytes.

Does DeepSeek Harness recovery restart rewrite a BOM?

No, the DeepSeek Harness recovery restart cannot rewrite the manifest. The first step of profile-sanitize reads the same manifest, and a parse failure throws before renameSync, so execution never reaches the write. The official README also states that invalid profile JSON fails before mutation. But that path still offers no way out for an unparseable manifest: it neither quarantines the bad file nor rolls back to the last good backup.

BOM gone but DeepSeek Harness still says Unexpected token?

For DeepSeek Harness, post the exact error line together with the first 8 bytes of the file. It is a pure BOM problem only when the first 8 bytes read EF BB BF 7B 0A 20 22. If the first 3 bytes are already 7B 0A 20 and parsing still fails, treat it as an ordinary JSON syntax error — a missing comma, unbalanced quotes, or a truncated file.

Related Terms

UTF-8 BOM
The UTF-8 BOM is the three bytes EF BB BF at the start of a file, historically used to mark UTF-8 encoding. RFC 8259 says writers of JSON MUST NOT add a BOM and parsers MAY ignore it, but many parsers skip that tolerance, so the BOM becomes the first illegal character.— https://github.com/deepseek-ai/deepseek-harness/discussions/11731
readProfileManifest
readProfileManifest is the DeepSeek Harness startup code that reads the profile manifest, around line 552 of packages/boot/app-boot/src/profile.ts. It reads with readFileSync(path, 'utf8') and calls JSON.parse directly at line 557, with no step that strips a BOM.— https://github.com/deepseek-ai/deepseek-harness/discussions/11731
profile-sanitize
profile-sanitize is the crash-recovery flow in DeepSeek Harness, implemented in packages/boot/app-boot/src/profile-sanitize.ts. It reads the same profile manifest first, and a parse failure throws before renameSync, so it does not rewrite the manifest — but it also offers no fallback for a manifest it cannot parse.— https://github.com/deepseek-ai/deepseek-harness/discussions/11731

Sources