Repository navigation
[No QA] Add patch so the Re.Pack dev server exits on Ctrl+C - #105612
Conversation
Raw mode clears the TTY's ISIG flag, so Ctrl+C is only deliverable as stream data. A stdin paused earlier by a CLI prompt's unpipe() delivers nothing, so the keypress listener never fires and the dev server cannot be interrupted.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
|
|
I'll review this PR soon |
Reviewer Checklist
Screenshots/Videos |
|
@kacper-mikolajczak
Step 7 of the Tests confirms that Ctrl+Z doesn't quit: Should we fix this as well? |
|
Hi @daledah, thanks for the feedback! I have checked and Ctrl+Z seems to never worked in Re.Pack, with or without this patch. The banner is an upstream bug from 2021. What my agent found out is, the Metro offers no Ctrl+Z either. With that said, I would do nothing for now at least to keep the parity and do not introduce too much complexity in the patches, where they would diverge from source. |
|
🚧 mountiny has triggered a test Expensify/App build. You can view the workflow run here. |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🧪🧪 Use the links below to test this adhoc build on Android, iOS, and Web. Happy testing! 🧪🧪
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.31-0 🚀
|
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.5.31-0 🚀
|
|
🚀 Deployed to production by https://github.com/blimpich in version: 9.5.31-4 🚀
Bundle Size Analysis (Sentry): |



Explanation of Change
Since native bundling moved to Re.Pack,
npm run ios/npm run android/npm run startcan start a dev server that ignores Ctrl+C: the port stays held and only an external signal stops the process. The dev server in@callstack/repackenters raw mode insetupInteractionswithout resumingprocess.stdin. Raw mode clears the TTY'sISIGflag, so the kernel stops turning Ctrl+C into SIGINT and the0x03byte is deliverable only as stream data. When a prompt was shown before the bundler starts (simulator picker, "port in use, use another port?"), the prompt framework closes withinput.unpipe(), and Node'sReadable.unpipe()callspause()on its source - so the stream delivers nothing, thekeypresslistener never fires, and theprocess.on('SIGINT')handler registered next to it is unreachable. Ther/d/j/ashortcuts are dead in the same session for the same reason.This PR adds a patch with the one-line fix:
process.stdin.resume()aftersetRawMode(true), which is what@rock-js/plugin-metrodoes on the same path (attachKeyHandlersresumes stdin right after entering raw mode, which is why the same flow always worked under Metro).Known gap this PR does not close: Ctrl+Z
setupInteractionsstill printsPress Ctrl+c or Ctrl+z to quit the dev server. Ctrl+Z has never worked in Re.Pack, before or after this patch; the banner is an upstream bug that predates the move to Re.Pack.Re.Pack maps
Ctrl+Ztoprocess.emit('SIGTSTP', 'SIGTSTP')(setupInteractions.js:37).process.emitonly runsprocess.on('SIGTSTP')listeners, and no such listener exists: grep over@callstack/repack,@rock-js/*and@callstack/repack-dev-serverfinds none, and searching all 972 upstream commits foron('SIGTSTP'or a self-kill(process.pid, 'SIGTSTP')returns nothing. Thecase 'z'arrived in5752810c(2021-03-08) already written asprocess.emit, so this line was never functional. Suspending needssetRawMode(false)thenprocess.kill(process.pid, 'SIGTSTP'). Measured after this patch: the emit does reach a testSIGTSTPlistener, and the process keeps running.Metro offers no Ctrl+Z either.
@react-native/community-cli-pluginand@rock-js/plugin-metrohandler/d/jplus Ctrl+C / Ctrl+D and their banners advertise only those. Fixing Ctrl+Z, or removing it from the banner, is an upstream change; this PR stays a one-line resume so it can be dropped when callstack/repack#1515 lands.Calling-side option
A
rock.config.mjswrapper aroundpluginRepack()can resume stdin fornpm run ios/android/ipad:@rock-js/configstores the bundler object and readsbundler.startat call time (config.js:67,:92), andplatformIOS.js:45passesgetBundlerStart()intocreateRun. It cannot covernpm run start, because@rock-js/plugin-repackregisters its ownstartcommand action calling its localstartDevServer(pluginRepack.js:26-29), bypassinggetBundlerStart. The durable fix belongs in@rock-js/plugin-repack, mirroringplugin-metro; that would also be acceptable to the upstream maintainers, who asked that this be fixed in the calling CLI rather than in Re.Pack.The patch is scoped to
@callstack/repack@5.4.1.setupInteractions.jsis byte-identical in 5.4.2 and the canary, so no version bump escapes it; drop the patch when upstream ships theresume().Upstream issue with reproduction and the same $ callstack/repack#1515
Fixed Issues
$ #105422
PROPOSAL:
Tests
npm i(orbun scripts/applyPatches.ts). Verify the output contains@callstack/repack@5.4.1 (2 resume-stdin-for-ctrl-c) ✔andpatch-package succeeded without errors or warnings.node_modules/@callstack/repack/dist/commands/common/setupInteractions.js. Verifyprocess.stdin.resume();followsprocess.stdin.setRawMode(true);.npm run iosso the device-selection prompt is shown. Pick a device and wait for the dev server to report it is listening.lsof -i :8081returns nothing).npm run iostwice at the same time so the second run shows the "port in use, use another port?" prompt. Confirm it, wait for the dev server, press Ctrl+C. Verify the process exits.r. VerifyReloading appis printed.Ctrl+Z. Verify the process keeps running and the banner text is unchanged - this patch does not alterCtrl+Z, see the Known gap section.Offline tests
Not applicable. Dev-server terminal handling only; nothing in this patch runs in the app or touches the network.
QA Steps
No QA. This changes the local dev-server process in a developer terminal; nothing ships in the app binary or the web bundle.
patchesis a fingerprintextraSourceinrock.config.mjs, so the native fingerprint changes and CI will not reuse prebuilt binaries for this branch, which is expected for any patch change.Evidence
Measured in a pseudo-terminal against the published
@callstack/repack@5.4.1tarball, with a prompt framework'sunpipe()teardown replayed before the dev server starts:rsetupInteractions.jsisPaused() === true,readableFlowing === falseisPaused() === false,readableFlowing === trueonReloadrunsPR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Both patches in
patches/@callstack/repack/apply together on a clean 5.4.1 install with--error-on-fail --error-on-warnand no conflicts, which is howscripts/applyPatches.tsruns them.Screenshots/Videos
Android: Native
No UI change.
iOS: Native
No UI change.