Feat/update node and other deps#102
Open
maagenta wants to merge 2 commits intoBoostIO:feat/update-node-and-other-depsfrom
Open
Feat/update node and other deps#102maagenta wants to merge 2 commits intoBoostIO:feat/update-node-and-other-depsfrom
maagenta wants to merge 2 commits intoBoostIO:feat/update-node-and-other-depsfrom
Conversation
…zation
PROBLEM
-------
After migrating to contextIsolation + contextBridge, file system IPC calls
broke for two related reasons:
1. Buffer → Uint8Array in contextBridge
fs.promises.readFile() returns a Buffer in the main process. When passing
through contextBridge, the structured clone algorithm serializes the Buffer
as a Uint8Array. In the renderer, readFileAsString() called result.toString(),
which on a Uint8Array inherits from Array.prototype.toString() and produces
comma-separated byte values ("123,104,101,...") instead of the actual file
content. JSON.parse() then failed with "Unexpected non-whitespace character
after JSON at position 3" because the first number ("123") is valid JSON but
the following comma is not.
The previous commit (53d6b89) tried to work around this by adding a separate
fs:read-text-file endpoint that read with 'utf8' encoding, avoiding the Buffer
entirely. That fixed readFileAsString but left the root cause unaddressed and
added unnecessary surface area to the IPC API.
2. error.code lost during IPC serialization (Electron 36+)
When the main process threw an error (e.g. ENOENT from stat on a missing
directory), Electron only preserves error.message when serializing exceptions
across IPC, not error.code. The catch blocks in prepareDirectory,
loadBoostNoteJSON and readdirOrEmpty were checking error.code === 'ENOENT',
which was always undefined in the renderer, causing the error to be re-thrown
instead of handled.
SOLUTION
--------
FSNoteDb.ts, ImportLegacyNotesForm.tsx, electronOnly.ts: simplifies the ENOENT
condition by replacing error.code === 'ENOENT' with error.message?.includes('ENOENT')
since error.code is not preserved when exceptions are serialized across IPC.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ate in Form
src/components/atoms/MarkdownPreviewer.tsx
- Wrap remarkAdmonitionOptions and rehypeReactConfig in useMemo to prevent
new object references on every render, which was causing markdownProcessor
and renderContent to be recreated continuously and firing the main useEffect
in a loop.
- Move navigateToNote above rehypeReactConfig so it can be a stable dependency.
- Remove renderedContent and rendering from the useEffect dependency array.
src/shared/components/molecules/Form/index.tsx
- Guard setSubmitState(false) behind a mountedRef to prevent a state update
on an unmounted component when the form submission closes its own modal.
- Replace the fire-and-forget async Promise with a direct await.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix IPC error.code loss and infinite render loop in MarkdownPreviewer
Summary
IPC error.code not preserved across Electron IPC: Electron does not
preserve
error.codewhen serializing exceptions through IPC, so catchblocks checking
error.code === 'ENOENT'inprepareDirectory,loadBoostNoteJSON, andreaddirOrEmptyalways receivedundefinedandre-threw instead of handling the error. Fixed by replacing the check with
error.message?.includes('ENOENT')inelectronOnly.ts,FSNoteDb.ts,and
ImportLegacyNotesForm.tsx.Infinite render loop in MarkdownPreviewer:
remarkAdmonitionOptionsand
rehypeReactConfigwere plain object literals recreated on everyrender, which invalidated
markdownProcessorandrenderContenton everyrender and kept firing the main
useEffectin a loop. Fixed by wrappingboth in
useMemo, movingnavigateToNoteaboverehypeReactConfigas astable dependency, and removing
renderedContentandrenderingfrom theuseEffectdependency array.State update on unmounted component in Form:
setSubmitState(false)was called inside a fire-and-forget Promise after
await onSubmit(), whichran after the component unmounted when the submission closed its own modal.
Fixed by awaiting
onSubmitdirectly and guarding the state update behinda
mountedRef.Verified