Repository navigation
fix: report hot reload readiness for apps that start the server directly - #70
Merged
Merged
Conversation
Since #57/#58, `ruflet run` queues "r" until the hot-reload harness reports on RUFLET_READY_FD that its USR1 trap is installed, and the harness only reported from the Ruflet.run interceptor. An app started with the DSL (`Ruflet.app { ... }.run` calls Ruflet::Server#start itself) or on a ruflet_core without Ruflet.with_run_interceptor never reported, so "r" printed "Reload queued" forever and file changes never reloaded either. - The harness also captures Ruflet::Server#start (a prepended hook in the CLI gem, active only while a hot-reload runner runs, never for the runner's own server), so those apps are reloaded and report ready like Ruflet.run apps. - The harness traps USR1 before loading any app code and reports that with a "t" byte; "." still means the app is up. - If an app has reported "t" but not "." within 5 seconds, `ruflet run` stops queueing and sends USR1 as before the queue existed. That is safe only after "t", so nothing is sent before it; the pipe stays open until the app closes it, so a late report never hits a closed pipe.
…lazily
Review follow-ups for the hot reload readiness change.
- Server#start is no longer captured process-wide while a runner is
active. The capture lives in a fiber-local set only while the runner
loads the app script, so only a start the script makes synchronously
(the one that would block that load without the runner) is captured.
Servers the app starts on its own threads or fibers, in children it
forks, or after the load are started as on v0.0.23, so an app that
serves from a background thread while its main script keeps running is
served again. Within one load only the first start is the app's; a later
one (never reached without the runner) is logged and ignored instead of
replacing the served block.
- The harness no longer requires ruflet_server before the app code.
ServerStartCapture is prepended once Ruflet::Server exists, through a
TracePoint on class bodies when the app loads it later. A DSL app that
never requires ruflet_server fails with the same NameError under
`ruflet run` as under plain ruby, as on v0.0.23.
- "t" (and ".") are only reported when Signal.trap("USR1") actually
succeeded; otherwise the fd is closed without a report, so `ruflet run`
never sends USR1 to an untrapped app.
- After "R", the old app's readiness fallback or a late "." can no longer
mark the session ready before the respawn: mark_restarting sets
:restarting, only spawn_app_child clears it, and mark_child_ready and
"r" respect it.
Second review round for the hot reload readiness change. A Server#start that the app script makes while the runner loads it is no longer replaced by the runner's own server and turned into a call that returns at once. On the first load the app's own server object serves the app from inside the script, as it does without the runner, and the runner only arms hot reload around it (watcher, USR1 trap, ready report) and makes that server serve the latest block. So: - code after `.run` runs once the server stops, as under plain ruby and v0.0.23; code there that blocks (joining a thread, a loop) no longer keeps the app from being served; - a Ruflet::Server subclass the app starts keeps its own behaviour; - a second start later in the script is reached only once the first server stops, and then runs as without the runner (it used to be ignored with a log line); - a server the script starts after an intercepted Ruflet.run runs as is, as on v0.0.23. On a reload, a captured start hands the new block over and ends the load there (throw), where the first load blocks; a script that keeps its server across loads (`$server ||= ...`) keeps serving it. The lazy Ruflet::Server hook now reads class names through Module#name and never raises into the class definition it watches: an app class that defines its own `name` with arguments made the TracePoint raise into it. Tests: subclass, blocking code after .run, second start after the first stops, start after an intercepted Ruflet.run, kept server, lazy hook with an odd `name` (fresh process), and an app serving from its own thread under the real harness: served, and "r" reaches only the USR1 trap.
…ess-fallback main (#72) now guards readiness after "R" with :retired_pid. This branch had its own :restarting flag for the same race; it now uses main's :retired_pid in mark_child_ready instead, so the readiness fallback and a late "." are both refused for the app "R" retired. "r" between the reap and the respawn is queued, as on main.
A script whose own server the runner served from inside the script, and which then calls Ruflet.run once that server stops, had that Ruflet.run intercepted and served by the runner's own server after the load on v0.0.23. The runner kept the stopped server as the one it serves instead, so it served nothing and the script ended. Once the app's own server stops, the runner now forgets it, so the rest of the script runs as on v0.0.23: a later Ruflet.run is served by the runner's server, with hot reload; a later Server#start runs as is. A script that hands nothing else over still ends without the "never called Ruflet.run" error.
The previous review planted six bugs in the server start capture that no
test caught. Each now fails a test:
- a forked child that captured its own start would arm a watcher and
report on the ready fd it inherited: the fork test now checks that the
child stays unarmed and that only the runner reports ("t.");
- a later start replacing the block on a reload: the test with a server
started after an intercepted Ruflet.run now also reloads;
- dropping the "@server already set" guard on the first load: new test
with a Ruflet.run on an app thread, then a start on the script's fiber;
- dropping the in-process-bridge guard: new test;
- not restoring the app's $VERBOSE, or leaving the script load set on the
fiber while the app's own server serves: new test that looks from
inside that server's accept loop.
Test-only: these all pass on the code as it was.
main.rb requires app.rb, and app.rb ends with `Ruflet.app { ... }.run`
(or starts Ruflet::Server itself, or calls Ruflet.run on a ruflet_core
without run interceptors). The runner serves that app's own server from
inside the script, so the main fiber serves from inside app.rb's require,
and Ruby holds that require's lock until the server stops. A reload loads
main.rb again on the watcher thread; its `require_relative "app"` waited
on that lock forever while holding the reload mutex. The app reported
ready, but no later save or "r" ever reloaded, and nothing was logged.
When the runner serves the app's own server, it now notes the files whose
require that start is nested in (the top-level frames between the start
and the script; "<main>" too, which is how bootsnap's compile cache labels
them). While a reload of such an app runs, and only then, a module
prepended to Object gives `require` and `require_relative` on the
reloading fiber a way past those locks: a require of one of those files
loads it there instead, once per reload, as `require` would. Every other
require, and every require on another fiber or thread, goes to Kernel's
own methods; outside such a reload the module has no methods at all. Once
the app's own server stops, those requires complete and later reloads
require the files as usual.
Apps that start the server in the script itself, and Ruflet.run apps in
any layout (which reloaded on v0.0.23, because the interceptor returns at
once and the require completes), never use any of this.
The tests that wait for the fallback popped a queue without a limit, so a fallback that never fired (the previous review removed its timer) showed only as a hung suite until the 60 s or 120 s guard. They now fail after 15 s, naming the fallback. The fallback fires at once in these tests (ready_fallback_seconds: 0); the limit is only that guard. The same for the required-file tests' wait for the ready report: an app that never reports now fails after 30 s instead of the session guard's 120 s timeout.
The PR says that during a reload of an app served from inside a required file, only the reloading fiber loads the files in flight, and that every other require goes to Kernel's own methods. Several planted bugs in that code passed every test. Each of these now fails one: - a require of a file in flight on another thread loaded it there: new test, where a `require` and a `require_relative` on two other threads wait on the require lock, as without the runner; - require_relative resolving against the caller's path instead of its real path: in that test, where the app's directory is reached through a symlink (macOS temp directories are), the other thread then loaded app.rb a second time, alongside the reload; - a same-named file elsewhere on $LOAD_PATH loaded instead of required: new test; - a file in flight required in another case (macOS file systems) not found, so the reload waited forever: new test, skipped on case-sensitive file systems; - require_relative from eval'd code not raising Kernel's LoadError: new test; - require_relative calling a Kernel#require wrapper (the harness sets bootsnap's up before it loads the runner) instead of the interpreter's own require: new test in a fresh process; - loading a file in flight returning false instead of true: the once-per-reload test now checks [true, false]. The once-per-reload test also stops the server main.rb starts after app.rb's own server stops. Before, nothing stopped it, and teardown waited 10 s for the runner thread. Test-only: these all pass on the code as it was.
On Ruby 3.3, 3.4.0-3.4.9 and 4.0.0-4.0.3 built with Prism, bootsnap
(1.24.5 and later) works around Ruby bug #22023 by compiling each file from
its source with InstructionSequence.compile. The top-level frames of those
files read "<compiled>", not "<top (required)>" or "<main>", so the
runner recorded no file in flight. main.rb requiring an app.rb that ends
with `Ruflet.app { ... }.run` then still hung on its first reload whenever
bootsnap was installed, which `ruflet run` sets up: the reload's
`require_relative "app"` waited on app.rb's require lock forever, exactly
as before 55bb36a. The PR's own bootsnap test failed on Ruby 4.0.0.
"<compiled>" now counts as a top-level frame too. The script's own top
level is also no longer found by its label: it is the bottom-most frame in
the script, so the boundary holds whatever a compile cache labels it, and
a method the script defines that runs above a file it requires is not
taken for it.
Tests: a compile-cache variant that compiles from source (it gives
"<compiled>" on every Ruby, so the gap fails on any Ruby); a start from a
script method called by a required file; and the bootsnap run_command
test accepts either label of bootsnap's cache.
A script that starts its own server unguarded and calls Ruflet.run once
that server stops:
$own = Ruflet::Server.new(...) { |page| page.add("own") }
$own.start
Ruflet.run { |page| ... }
After the own server stops, the runner serves the Ruflet.run block. A
save re-runs the script from the top, so the reload reached `$own.start`
first, took it for the load's entrypoint, and repainted every client with
the stopped server's block instead of the Ruflet.run UI. On v0.0.23 and
main that reload started the own server again on the watcher thread and
never finished.
On the first load that start returned once its server stopped. On a
reload after the runner has let that server go, a captured start before
the load's entrypoint now returns at once, without starting anything, so
the load goes on to the Ruflet.run, as under plain ruby once that server
has stopped. Nothing else changes: while the app's own server serves, a
reload still ends at its start.
While the app's own server serves, $VERBOSE is the app's again, not the nil the load sets. Once that server stopped, it stayed that way for the rest of the script (the code after `.run`), which on v0.0.23 and main runs inside the load with warnings silenced: a constant redefined after `.run` printed "already initialized constant" under `ruflet run` only on this branch. The runner now gives the rest of the script back the $VERBOSE the load had when the start was captured. Also: a script that sets $VERBOSE itself while it loads (`$VERBOSE = true` at the top of main.rb) had that setting replaced, while its server served, by the one from before the load. It now keeps its own, as on v0.0.23 and main; only the nil the load set is replaced.
…race Three planted bugs passed every test: - READY_FALLBACK_SECONDS = 0. Every fallback test passed its own window, so nothing pinned the 5 s that bounds the disclosed case where a queued "r" reaches a USR1 handler the app installed itself. A test now pins the default `ruflet run` uses, and another checks that the fallback fires no sooner than its window after "t" (a lower bound, which holds on any machine). - The TracePoint left enabled after `class Ruflet::Server` opens. The fresh-process hook test now checks that the trace is on until then and off after. - "t" reported only after the run-interceptor check, so an app on a ruflet_core without run interceptors never reported its trap and never got the fallback. The trap-before-load test now has a twin on such a core. Test-only: these all pass on the code as it was.
…stopped The previous commit lets a reload go past starts that come before its entrypoint once the app's own server has stopped. A start after that Ruflet.run must still end the reload, as for any Ruflet.run app whose script starts a server after it: dropping the entrypoint condition made the reload run the code after that start. This pins it.
The runner silences warnings while it loads the app script ($VERBOSE = nil) and, when the app's own server serves from inside that load, restored the value from before the load whenever it found nil. A script's own `$VERBOSE = nil` was indistinguishable from the load's and was replaced, so warnings that v0.0.23 and plain ruby keep silent printed under `ruflet run`. The first load now traces assignments to $VERBOSE, $-v and $-w until the app's own server starts serving, and keeps whatever value the load left when anything assigned it. The trace is removed before the server serves and when the load ends.
Without the runner, a USR1 handler the app installs runs on every USR1 (on v0.0.23, `r` ran it too). While the app's own server serves from inside its script, arming hot reload replaced that handler with the runner's trap, so `r` and any outside USR1 reloaded the app and the app's handler never ran again, not even once the server had stopped. AppTrapChain now traps USR1 while that server serves: USR1 asks for a reload and then calls the handler the app installed, with the signal number, as Ruby does. A reload, which traps USR1 again from the top of the script, is chained the same way, also when it fails. Once the server stops, the app's latest handler is put back unless the app has trapped USR1 again since. Command-string handlers (IGNORE, DEFAULT, EXIT, ...) are not run while serving, only put back. Ruflet.run apps keep the handling they have on v0.0.23 and main.
The $VERBOSE tests name $VERBOSE, $-v and $-w themselves instead of reading ScriptLoad::VERBOSE_GLOBALS, and a USR1 handler that never runs fails its test with a message instead of erroring out of Timeout, so on a tree without these fixes they fail on the behaviour they pin.
A common idiom chains a USR1 handler to the handler it replaced:
`previous = Signal.trap("USR1") { |s| ...; previous.call(s) }`. While the
app's own server serves, a reload traps USR1 again while AppTrapChain is
installed, so that handler's `previous` is the chain itself, which runs
that same handler. Since 4863c40 the two called each other on the next
USR1 until a SystemStackError ended the app, and once the server stopped
every USR1 did.
The chain now does nothing when it is called while it runs the app's
handler, and runs the app's handler only while it is armed: after
restore the app's latest handler is the trap itself. The runner's own
handler, which the first load's handler calls, asks for no second reload
while the chain runs the app's handler, so each USR1 asks for one
reload. The flag is reset in an ensure, so a handler that raises does
not leave the chain silent.
Tests: the idiom over three USR1s and reloads and once the server
stopped; no second reload when the handler calls the replaced handler
after the reload began; a handler that raises; USR1 once the app's own
server stopped and the runner serves the Ruflet.run after it (the chain
is not armed again: pins `@armed = false` in restore); and `ruflet run`'s
own spawn with `r` three times for the idiom.
This was referenced Nov 17, 2026
…andler assert_r_reloads_and_runs_the_apps_handler ignored its `presses:` keyword: the loop was hard-coded to two presses and the assertion to two USR1s, so the chaining-idiom caller that asks for three pressed `r` twice. The loop now runs `presses` times and expects one USR1 per press. AppTrapChain#take_over keeps the app's handler when a reload leaves the chain itself as the trap (`unless previous.equal?(@handler)`). Since the re-entry guard of 8296f41 nothing failed without that check, yet an app that installs its USR1 handler only on the first load (`$trapped ||= Signal.trap("USR1") { ... }`, or a handler from a gem or a file that is not reloaded) then never runs it again after the first reload. New test: three USR1s each run that handler once and reload, and once the server stops a USR1 runs it once. With the check removed it fails with "the app's handler on USR1 2 never ran".
This was referenced Nov 18, 2026
AdamMusa
added a commit
that referenced
this pull request
Nov 20, 2026
#75 split build_command.rb into cli/build/ modules and turned prepare_flutter_client's steps into registered contributors. The seam is carried into that layout: - build_command.rb requires client_bootstrap and includes ClientBootstrap next to FlutterSdk, as before. - The write_client_bootstrap call, which ran right after the extension selection was applied and verified, is now the startup_hooks contributor (cli/build/contributors/startup_hooks.rb), registered after :extensions, so it still runs at that point, before assets and before Flutter. - build_contributors_test pins startup_hooks in that place in BUILT_IN and checks that the contributor passes the build on and always continues.
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.
Problem
Since #57 and #58,
ruflet runholds anrpressed during boot until the hot-reload harness writes a byte onRUFLET_READY_FD. The harness wrote that byte only on theRuflet.runinterceptor path, and two ways of starting an app never take it:Ruflet.app { ... }.run,app { ... }.run,Ruflet::DSL::App#run) and scripts that callRuflet::Server.new(...).startthemselves.ruflet_corewithoutRuflet.with_run_interceptor: the harness logged "running without hot reload" and never reported.For those apps every
rprintedReload queued: the app is still starting and will reload once it is up, and nothing reloaded. The file watcher never started either, so saves did nothing. On Ctrl-C the session ended withHotReload::Error: ... never called Ruflet.runand exit 1. The end-to-end table under "Verification" shows this on main.The reviews of this PR found more cases on the same path. All of them are fixed here:
main.rbdoesrequire_relative "app"). The first reload hung on that require's lock. That includes the case where bootsnap compiles the file from source, so its frames read<compiled>.$VERBOSE = nilwas replaced while its server served.previous = Signal.trap("USR1") { |s| ...; previous.call(s) if previous.respond_to?(:call) }) recursed until aSystemStackErrorended the app. This was a regression in4863c406, fixed in8296f411.Fix (
packages/rufletonly)The PR changes
lib/ruflet/hot_reload.rb,lib/ruflet/cli/run_command.rband their two test files.ruflet_core,ruflet_server,ruby_runtime, the template and the engine are untouched.Server#start.HotReload::ServerStartCaptureis prepended toRuflet::Serveronce the app defines that class. It acts only on a start that the script makes synchronously, on the fiber that loads it, while the runner loads it.@app_blockat the latest loaded block.throw). A script that keeps its server across loads ($server ||= ...) keeps serving it.ruby. A laterRuflet.runis served by the runner's own server, with hot reload. On a reload, the stopped server's start returns at once without starting anything.$VERBOSEis the app's own while that server serves. That is the value from before the load, unless something assigned$VERBOSE,$-vor$-wwhile the script loaded (seen throughtrace_var), in which case it is what the load left.AppTrapChain). While that server serves, USR1 asks for one reload and then runs the handler the app installed, with the signal number."IGNORE"and the like) is not run while the server serves, and it is put back when the server stops.Ruflet.run. They run as without the runner.requirethe start is nested in. Those are the top-level frames (<top (required)>,<main>or<compiled>) above the script's own bottom-most frame.HotReload::InFlightRequires(prepended toObject) letsrequireandrequire_relativeof those files load them on the reloading fiber, once per reload.ruflet_serveris still loaded by the app. ATracePoint(:class)waits forclass Ruflet::Serverto open, then disables itself.tonly if that trap succeeded, and.only once the trap is in place again after the app code. Otherwise it closes the fd without reporting, soruflet runnever sends USR1 to an untrapped app.run_command.rb). Suppose an app has reportedtbut not.withinREADY_FALLBACK_SECONDS(5 s).ruflet runthen sends the queuedras USR1, the old way. The harness's early trap keeps that signal and applies it once the watcher runs. Nothing is sent beforet.Rand the old app's late report.mark_child_readyuses main's:retired_pidguard (New controls and their protocol, client actions, local auth, and review follow-ups #72). Neither a late.nor the old app's fallback can then mark the session ready betweenRand the respawn.What changes for existing apps
ruflet run --no-reloadand plainruby main.rb: no change, because the harness is not used. The CLI's options and messages are unchanged.Ruflet.runapps: no change, except as follows.rpressed during boot is still queued and applied once the app is up, as on main.ris sent at the fallback instead of at the ready report. It is still applied once, after boot, as on main, unless the app's own code replaced the USR1 trap by then. Then thatrruns the app's handler and does not reload (with"DEFAULT"it ends the app, as anyrduring boot did on v0.0.23).Ruflet.runfollowed by a synchronousServer#start. The other is the app's ownstartfollowed byRuflet.run. On v0.0.23 and main, the first reload of either blocked in a new server's start until Ctrl-C, and later saves did nothing. Now every save reloads, and nothing more is bound.Ruflet::Serversynchronously, in the script or in a file it requires, are served by their own server as before. They now also get hot reload:@app_blockis replaced by one that renders the latest block.Ruflet.runapps always have.loads the files that hold the start.$VERBOSEwhile loading. This is the one change from v0.0.23, where that server ran inside the harness's silenced load. A script's own$VERBOSE = nilalso silences the harness'sreloaded inlines, asRUBYOPT=-W0does on main.rand outside USR1, and has its handler back once the server stops. On v0.0.23,rran only the handler; on main,rstayed queued.HotReload::Errorbacktrace.Kernel.requireorKernel.require_relativereceiver, or inside a lock the script holds while serving. The app keeps being served, but saves andrdo nothing.rreaches the harness's trap at the fallback, where it does nothing. On v0.0.23 it killed the app; on main it stayed queued.Ruflet::Serverper reload of a DSL app;TracePointuntilRuflet::Serveris defined;trace_varon the$VERBOSEnames during the first load;InFlightRequiresmodule inObject's ancestors after the first reload;realpathper stack frame when the app's own server starts.Tests
The new tests are deterministic. They synchronise on FIFOs, pipes, queues and polling, and their timeouts only stop hangs. Two tests depend on timing:
test_the_ready_fallback_waits_its_window_after_the_trap_reportchecks a lower bound on time.test_a_usr1_handler_that_calls_the_one_it_replaced_asks_for_no_second_reloadwaits 0.5 s to see that no second reload follows.The two files:
test/hot_reload_test.rb: 57 new tests, 70 runs in the file. They cover DSL and direct starts; required files, also under compile caches that label frames<main>and<compiled>; requires during such a reload;$VERBOSE; and the app's own USR1 handlers. Two byte-protocol assertions change from.tot..test/run_command_test.rb: 16 new tests, 51 runs in the file. They drive the real harness in a child process,ruflet run's own spawn and readiness pipe, and the fallback's pipe-level watcher.read_progressgains an optional byte count, and the existing boot-queue tests passready_fallback_seconds: nil.New this round (
15274af0, tests only):assert_r_reloads_and_runs_the_apps_handlernow pressesrpresses:times and expects one USR1 per press; before, it always pressed twice. Sotest_r_reloads_a_dsl_app_whose_usr1_handler_calls_the_one_it_replacedpressesr3 times, andtest_r_reloads_a_dsl_app_that_traps_usr1_itself_and_still_runs_its_handlerstill presses it twice.test_a_usr1_handler_installed_only_on_the_first_load_runs_on_every_usr1uses$usr1_trapped ||= Signal.trap("USR1") { ... }. Three USR1s each run that handler once and reload, and once the server stops, a USR1 runs it once. This pins theunless previous.equal?(@handler)check inAppTrapChain#take_over.Verification (this round, on the final head
15274af0)Homebrew Ruby 4.0.5,
GEM_HOMEunset, no-W0, one process per test file.Scope.
git diff --stat origin/main...HEADlists only the 4 files above.git diff origin/main...HEAD -- packages/ruflet_core packages/ruflet_server ruby_runtime toolsis empty. The embedded VM compiles onlyruflet_core/libandruflet_server/lib(ruby_runtime/vm/mrbgems/ruflet-framework/mrbgem.rake), so this PR changes nothing it builds.git diff --quiet 8296f411 HEAD -- packages/ruflet/libsucceeds: the lib is unchanged since the last review.Suites, file by file:
ruflet_coreruflet_serverruflethot_reload_test70 runs,run_command_test51)ruflet_railsThe worktree stayed clean.
Other Rubies, both files, all passing: rbenv 4.0.0 (bootsnap 1.24.6), rbenv 3.4.5 (bootsnap 1.26.1), and Homebrew 3.2.9 without bootsnap (its bootsnap test is skipped).
Under load: both files 30 times in a row, twice.
run_commandtests that wait for the harness'sreloaded inline between presses ofr.Planted bugs: 83 bugs, each planted alone in a copy of this head with both files run against it, four copies at a time. An unplanted copy passed both files.
$VERBOSE, the fallback andAppTrapChain.take_overcheck. It failstest_a_usr1_handler_installed_only_on_the_first_load_runs_on_every_usr1with "the app's handler on USR1 2 never ran"; last round it passed both files.rescues: norescueinRequiresInFlight#path_for, where a bad feature then raises what Kernel'srequireraises;nameinstead ofModule#name, or norescue, in theTracePoint, two guards for one case (an app class whosenametakes arguments).InFlightRequires' methods defined, or the module prepended, on every reload; nouniqon the in-flight files, which are hash keys.@app_blockguard; no autoload guard (nothing registers an autoload forRuflet::Server);.sofeatures not told apart (only.rbfiles are recorded); in-flight files keyed by path rather than real path; frames without a path not skipped (CRuby reports none).throw; a secondtresetting the fallback deadline (tis reported once per process); reloads tracing$VERBOSEtoo (a reload never serves, and its trace goes when it ends).AppTrapChainchecks covered elsewhere: the runner's own trap chained as the app's handler (that call asks for nothing while the chain runs); noStringcheck (no command string responds tocall);restorewithout its armed check (it only followsarm); a nested call to the chain still calling the runner's handler (which asks for nothing while the chain runs the app's).Older libs, with this head's two test files:
4e526dc4, the head before8296f411:hot_reload_test: 3/70 fail. The two idiom tests error withSystemStackError, and the no-second-reload test sees 2 reloads.run_command_test: 1/51 fails. The chaining test's secondrreads["H2", "H2"].095cbf55:hot_reload_test: 50/70 fail (47 failures, 3 errors). Two errors come from the new API (HotReload.hook_server_start,HotReload::SERVER_START_CAPTURE). The third is aNoMethodErrorin the unguarded own-server test, which renders a nil block. Among the tests that pass aretest_a_ruflet_run_apps_own_usr1_handler_is_replaced_once_it_is_up_as_before,test_ruflet_run_in_a_file_the_script_requires_reloadsandtest_files_are_required_again_once_the_apps_own_server_stops.run_command_test: 14/51 fail (11 failures, 3 errors). This run uses a shim that only letsnew_run_stateacceptready_fallback_seconds:. The failures include the fallback tests (main has noREADY_FALLBACK_SECONDS), the DSL and no-interceptor boot tests, the two DSL required-file tests and the two USR1 tests.H1 goldens: origin/main
4f64623d(which now includes test: CLI and page compatibility goldens (WP-00 H1) #73, refactor: page prop, Page event and page method registries (WP-00 R4) #74 and refactor: split build_command.rb into cli/build modules (WP-00 R1) #75) is merged into this branch as87754aa7; against main the branch still changes only its 4 files. On87754aa7,ruby packages/ruflet/test/compat/compat.rbchecked 234 goldens (exit 0),compat_goldens_test.rbpassed 242 runs, everypackages/ruflet/testfile passed, includinghot_reload_test(70 runs) andrun_command_test(51 runs).Other PRs:
git merge-treeof this head with each open PR's head is clean: fix: read client-synced control state like event.control.value #71, refactor: page prop, Page event and page method registries (WP-00 R4) #74-CLI: cover every command and option, fix what the tests exposed #84, Test every control, service and shipped extension against its wire contract #86-ruflet_record: fix six bugs the coverage tests exposed; test the untested public API #90.b40acdd3, not modified) shares no file with this PR. On the merged tree, all 17packages/ruflettest files pass.cli/run_command.rb, in other places.End to end: a real
ruflet runin a pty, driven by keys, saves, signals and port probes, then Ctrl-C. Trees: v0.0.23, main095cbf55and this head.main.rb:r,r, a saverkills the app, and the session ends (exit 1)ris queued and the save does nothing; Ctrl-C printsHotReload::Error(exit 1)rand the save reload; exit 0app.rb, required bymain.rb(bootsnap 1.24.6):r,r, a save ofapp.rb.run, then after the require; exit 0r3 times, then an outside USR1HotReload::Error(exit 1)ris queued, the USR1 runs the handler, and nothing reloads (exit 1)Ruflet.run: two savesRuflet.run, then a directstart(stopped after 3 s): two savesRuflet.runapp that loads for 2 s, withrpressed at oncerkills the booting app (exit 1)r$VERBOSEisniland no warning shows; therkills the app (exit 1)nil, no warning; theris queued (exit 1)false, and the warning shows; therreloads; exit 0$VERBOSE = nilnil, no warning; therkills the app (exit 1)nil, no warning; theris queued (exit 1)nil, no warning; therreloads with noreloaded inline; exit 0r, then 8 srkills it (exit 1)This head only, each session exiting 0:
$trapped ||= Signal.trap("USR1") { ... }).r3 times and an outside USR1 each run that handler once and reload. On Ctrl-C it is back and runs once.main.rbdoesKernel.require_relative "app", or wrapsrequire_relative "app"in aMonitor#synchronize. In both, a save andrdo not reload, and the app stays served, as listed under "Still not reloaded". On Ctrl-C, the code after.runand after the require runs.CI: on
15274af0, 11 checks passed and 1 was skipped (publish). On4adf04ae(mainc2d547b9merged), all 11 passed, and Verify Ruflet Explorer rancompat_goldens_test.rb(242 runs, 0 failures). CI runs again on87754aa7.Not run this round, because their inputs are unchanged: Flutter (the engine and template are untouched), a VM rebuild, and the doc harness (none of its examples goes through
ruflet run).