Hot fix/182 fix version and post extraction#183
Conversation
- Inject VITE_APP_VERSION from package.json at build time via vite.config.ts define, so production builds no longer compare undefined to the latest release version - Return an error object from firstFrame.ts on extraction failure instead of undefined, preventing a downstream TypeError in the renderer - Dispatch setLoading(false) in the catch block of onSetVideoParameters so the UI always unfreezes even when extraction fails
There was a problem hiding this comment.
Code Review
This pull request bumps the application version from 3.5.0 to 3.5.1 across several configuration and documentation files, and improves error handling when extracting the first frame. Specifically, the Electron IPC handler now returns caught errors, and the frontend hook throws an error and resets loading states accordingly. Feedback on these changes includes a recommendation to check if the IPC result is nullish to prevent a potential TypeError when accessing its properties, and a suggestion to use path.resolve with __dirname when reading package.json in the Vite configuration to avoid issues with varying working directories.
| if (result?.error) { | ||
| throw new Error(result.error); | ||
| } |
There was a problem hiding this comment.
If result is null or undefined (e.g., due to an IPC failure), result?.error will evaluate to undefined and no error will be thrown here. However, on line 230, result.initial_frame is accessed directly, which will trigger a TypeError. Checking if result itself is nullish prevents this potential crash.
| if (result?.error) { | |
| throw new Error(result.error); | |
| } | |
| if (!result || result.error) { | |
| throw new Error(result?.error || 'Failed to extract first frame'); | |
| } |
| import react from '@vitejs/plugin-react'; | ||
| import * as os from 'os'; | ||
|
|
||
| const { version } = JSON.parse(readFileSync('./package.json', 'utf-8')); |
There was a problem hiding this comment.
Using a relative path like './package.json' relies on the current working directory (CWD) of the process running Vite. If Vite is executed from a different directory (e.g., the repository root or via a monorepo task runner), this read will fail. Resolving the path relative to __dirname using path.resolve is much more robust.
| const { version } = JSON.parse(readFileSync('./package.json', 'utf-8')); | |
| const { version } = JSON.parse(readFileSync(path.resolve(__dirname, 'package.json'), 'utf-8')); |
Summary
Fix false "new version available" warning:
VITE_APP_VERSIONwas only defined in.env.development, so production builds hadundefinedas the current version, triggering the warning on every launch. Fixed by injecting the version frompackage.jsonat build time via Vite'sdefineoption.Fix frozen spinner after frame extraction:
riverCli()was fire-and-forget, causing the IPC handler to return before extraction finished. Also, on extraction failure the catch block returnedundefined, triggering a TypeError in the renderer that leftisLoading = trueindefinitely. Fixed by awaitingriverCli()and returning a proper error object from the catch block.Version bump: 3.5.0 → 3.5.1