-
Notifications
You must be signed in to change notification settings - Fork 2
fix(notion-datasource-sync): notion db sync/track work under packaged Node #898
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
Open
schickling-assistant
wants to merge
2
commits into
main
Choose a base branch
from
schickling-assistant/2026-07-07-notion-db-packaged-node
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
67 changes: 67 additions & 0 deletions
67
packages/@overeng/notion-datasource-sync/src/cli/sync-progress-fallback.unit.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { Effect } from 'effect' | ||
| import { afterEach, describe, expect, it } from 'vitest' | ||
|
|
||
| import { runWithCliSyncProgress } from './main.ts' | ||
| import type { CliCommand } from './main.ts' | ||
|
|
||
| /** | ||
| * Regression guard for the packaged-Node `.tsx` import defect. | ||
| * | ||
| * `runWithCliSyncProgress` optionally loads the TUI progress UI via dynamic | ||
| * `import('@overeng/tui-react')`. `@overeng/tui-react` is a `.tsx` module; under | ||
| * a runtime that cannot strip JSX (plain packaged Node) that import REJECTS, | ||
| * which `Effect.promise` surfaces as a **defect** (die), not a typed failure. | ||
| * | ||
| * The bug: the fallback used `Effect.either`, which does NOT catch defects, so a | ||
| * failed load bypassed `runWithPlainSyncProgress` and the command died with zero | ||
| * output (exit 1). The fix promotes the defect onto the error channel before | ||
| * `Effect.either`, so any load failure cleanly degrades to plain progress. | ||
| * | ||
| * This test injects a loader that reproduces the real failure mode — a rejected | ||
| * dynamic import via `Effect.promise` (a die) — and asserts the command still | ||
| * completes AND observably ran plain progress (it writes phase lines to stderr). | ||
| * No network, no real `.tsx` transpile (vitest transpiles `.tsx` fine, so the | ||
| * real import cannot fail here — injecting the raw dying loader is what exercises | ||
| * the defect path). Deleting the `catchAllDefect` line in `main.ts` makes this | ||
| * test crash, confirming it is a genuine RED guard. | ||
| */ | ||
| describe('runWithCliSyncProgress TUI-load fallback', () => { | ||
| const originalWrite = process.stderr.write.bind(process.stderr) | ||
|
|
||
| afterEach(() => { | ||
| process.stderr.write = originalWrite | ||
| }) | ||
|
|
||
| // Reproduce the packaged-Node failure: a rejected dynamic import surfaced by | ||
| // `Effect.promise` as a defect (die), NOT a typed failure. Injecting past the | ||
| // fix (e.g. `Effect.fail`) would prove nothing — the whole point is the defect. | ||
| const dyingTuiLoader = Effect.promise(() => | ||
| Promise.reject(new Error('Node cannot strip JSX from @overeng/tui-react (.tsx)')), | ||
| ) as ReturnType<typeof Effect.succeed<never>> | ||
|
|
||
| it('falls back to plain progress when the TUI import dies (defect), instead of crashing', async () => { | ||
| const command: CliCommand = { _tag: 'doctor' } | ||
|
|
||
| const captured: Array<string> = [] | ||
| process.stderr.write = ((chunk: string | Uint8Array): boolean => { | ||
| captured.push(typeof chunk === 'string' ? chunk : Buffer.from(chunk).toString('utf8')) | ||
| return true | ||
| }) as typeof process.stderr.write | ||
|
|
||
| const result = await Effect.runPromise( | ||
| runWithCliSyncProgress({ | ||
| command, | ||
| effect: Effect.succeed('command-ran'), | ||
| loadTui: dyingTuiLoader, | ||
| }), | ||
| ) | ||
|
|
||
| process.stderr.write = originalWrite | ||
|
|
||
| // The command's own effect still ran and produced its value... | ||
| expect(result).toBe('command-ran') | ||
| // ...and the fallback observably used PLAIN progress (stderr phase lines), | ||
| // not the TUI, and did not crash on the load defect. | ||
| expect(captured.join('')).toContain('notion db doctor complete 100%') | ||
| }) | ||
| }) |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all this added complexity suggests we probably want to refactor this in a more principled way to avoid the bun vs node complexity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed that removing the Bun/Node runtime split would be the more principled architectural direction. This PR is intentionally narrower: it repairs the packaged
notion db trackpath by adding the missing route and adds failure-capable coverage for the runtime boundary that currently exists. Eliminating that boundary would expand this focused defect repair into a broader CLI/runtime redesign. The PR body already records the immediate structural risk under Follow-ups: the routed-verb list is hand-duplicated from the CLI definitions and can drift again, so it should ultimately come from one source of truth. Do you want that architectural refactor to block this repair, or is it acceptable as follow-up work?