@@ -16,20 +16,21 @@ import { checkFxProviderStatus } from "./status.ts";
1616const encoder = new TextEncoder ( ) ;
1717const settings = Schema . decodeSync ( FxSettings ) ( { enabled : true } ) ;
1818
19- /** A `stalled` process has started but never writes output or exits . */
20- function processHandle ( stdout : string , code : number , stalled = false ) {
19+ /** Holds stdout and the exit back until `answered` completes, like a CLI slow to answer . */
20+ function processHandle ( stdout : string , code : number , answered : Effect . Effect < void > = Effect . void ) {
2121 return ChildProcessSpawner . makeHandle ( {
2222 pid : ChildProcessSpawner . ProcessId ( 900_000_101 ) ,
23- exitCode : stalled ? Effect . never : Effect . succeed ( ChildProcessSpawner . ExitCode ( code ) ) ,
23+ exitCode : Effect . as ( answered , ChildProcessSpawner . ExitCode ( code ) ) ,
2424 isRunning : Effect . succeed ( false ) ,
2525 kill : ( ) => Effect . void ,
2626 unref : Effect . succeed ( Effect . void ) ,
2727 stdin : Sink . drain ,
28- stdout : stalled
29- ? Stream . never
30- : stdout . length === 0
31- ? Stream . empty
32- : Stream . succeed ( encoder . encode ( stdout ) ) ,
28+ stdout : Stream . unwrap (
29+ Effect . as (
30+ answered ,
31+ stdout . length === 0 ? Stream . empty : Stream . succeed ( encoder . encode ( stdout ) ) ,
32+ ) ,
33+ ) ,
3334 stderr : Stream . empty ,
3435 all : Stream . empty ,
3536 getInputFd : ( ) => Sink . drain ,
@@ -38,7 +39,7 @@ function processHandle(stdout: string, code: number, stalled = false) {
3839}
3940
4041/** Answers `fx` invocations by their arguments and records which ran. */
41- const check = ( statusJson : string , versionDelay : Duration . Input = 0 , versionStalls = false ) =>
42+ const check = ( statusJson : string , versionDelay : Duration . Input = 0 ) =>
4243 Effect . gen ( function * ( ) {
4344 const outputs : Record < string , string > = {
4445 "--version" : "fx 0.0.13\n" ,
@@ -58,12 +59,12 @@ const check = (statusJson: string, versionDelay: Duration.Input = 0, versionStal
5859 const args = ChildProcess . isStandardCommand ( command ) ? command . args . join ( " " ) : "" ;
5960 invoked . push ( args ) ;
6061 const stdout = outputs [ args ] ;
61- if ( args !== "--version" ) {
62- return Effect . succeed ( processHandle ( stdout ?? "" , stdout === undefined ? 2 : 0 ) ) ;
63- }
64- return Effect . delay (
65- Effect . succeed ( processHandle ( stdout ?? "" , 0 , versionStalls ) ) ,
66- versionDelay ,
62+ return Effect . succeed (
63+ processHandle (
64+ stdout ?? "" ,
65+ stdout === undefined ? 2 : 0 ,
66+ args === "--version" ? Effect . sleep ( versionDelay ) : Effect . void ,
67+ ) ,
6768 ) ;
6869 } ) ;
6970 const draft = yield * checkFxProviderStatus ( settings , { } ) . pipe (
@@ -77,7 +78,6 @@ describe("checkFxProviderStatus", () => {
7778 {
7879 label : "answers after 6 s" ,
7980 versionDelay : "6 seconds" ,
80- versionStalls : false ,
8181 status : "ready" ,
8282 version : "0.0.13" ,
8383 message : undefined ,
@@ -86,16 +86,6 @@ describe("checkFxProviderStatus", () => {
8686 {
8787 label : "never answers" ,
8888 versionDelay : "Infinity" ,
89- versionStalls : false ,
90- status : "error" ,
91- version : null ,
92- message : "Failed to run `fx --version`." ,
93- invoked : [ "--version" ] ,
94- } ,
95- {
96- label : "starts but never answers" ,
97- versionDelay : 0 ,
98- versionStalls : true ,
9989 status : "error" ,
10090 version : null ,
10191 message : "Failed to run `fx --version`." ,
@@ -106,7 +96,6 @@ describe("checkFxProviderStatus", () => {
10696 const fiber = yield * check (
10797 JSON . stringify ( { kind : "status" , model : "anthropic/claude-opus-5.5" , auth : "fx login" } ) ,
10898 row . versionDelay ,
109- row . versionStalls ,
11099 ) . pipe ( Effect . forkChild ) ;
111100 yield * TestClock . adjust ( "10 seconds" ) ;
112101 const { draft, invoked } = yield * Fiber . join ( fiber ) ;
0 commit comments