@@ -98,7 +98,7 @@ function runOperation(
9898 execFile (
9999 command ! ,
100100 [ ...( preload ? [ '--import' , pathToFileURL ( preload ) . href ] : [ ] ) , ...prefix , ...args ] ,
101- { cwd, encoding : 'utf8' , timeout : 20_000 , env } ,
101+ { cwd, encoding : 'utf8' , timeout : 20_000 , maxBuffer : 128 * 1024 * 1024 , env } ,
102102 ( error , stdout , stderr ) =>
103103 resolve ( { status : error ? Number ( error . code ) || 1 : 0 , stdout, stderr } ) ,
104104 ) ;
@@ -166,43 +166,56 @@ it.each([true, false])(
166166 15_000 ,
167167) ;
168168
169- it ( 'requests immutable version source explicitly without loading or provisioning build output' , async ( ) => {
170- const directory = temporaryDirectory ( 'void-cf-secret-source-' ) ;
171- const draft = voidSecretDraftVersion ( ) ;
172- const requests : Array < string > = [ ] ;
173- const userAgents : Array < string | undefined > = [ ] ;
174- const api = await listen (
175- createServer ( ( request , response ) => {
176- requests . push ( request . url ?? '' ) ;
177- userAgents . push ( request . headers [ 'user-agent' ] ) ;
178- request . resume ( ) ;
179- response . writeHead ( 200 , { 'Content-Type' : 'application/json' } ) ;
180- response . end ( JSON . stringify ( { success : true , errors : [ ] , messages : [ ] , result : draft } ) ) ;
181- } ) ,
182- ) ;
183- const configPath = join ( directory , 'wrangler.json' ) ;
184- writeFileSync ( configPath , JSON . stringify ( { name : 'test-worker' , account_id : 'test-account' } ) ) ;
185- const output = await runOperation (
186- directory ,
187- {
188- type : 'versions.view' ,
189- versionId : draft . id ,
190- includeSource : true ,
191- configPath,
192- workerName : 'test-worker' ,
193- } ,
194- { ...tokenEnv ( api ) , CLI_VERSION : 'inherited-version void/stale' } ,
195- ) ;
196- expect ( output . status , output . stderr ) . toBe ( 0 ) ;
197- const result = decodeCloudflareOperationResult ( { status : 0 , stdout : output . stdout , stderr : '' } ) ;
198- expect ( result . status ) . toBe ( 0 ) ;
199- expect ( isVoidSecretOnlyDraft ( result . data as Record < string , unknown > ) ) . toBe ( true ) ;
200- expect ( requests ) . toEqual ( [
201- `/client/v4/accounts/test-account/workers/workers/test-worker/versions/${ draft . id } ?include=modules` ,
202- ] ) ;
203- expect ( output . stdout ) . not . toContain ( 'synthetic-token' ) ;
204- expect ( userAgents ) . toEqual ( [ `cf-cli/${ cfVersion } void/${ voidVersion } ` ] ) ;
205- } ) ;
169+ it . each ( [ false , true ] ) (
170+ 'requests immutable version source without provisioning (large=%s)' ,
171+ async ( large ) => {
172+ const directory = temporaryDirectory ( 'void-cf-secret-source-' ) ;
173+ const draft = voidSecretDraftVersion ( ) ;
174+ if ( large ) {
175+ draft . modules [ 0 ] ! . content_base64 = Buffer . from (
176+ `/* ${ 'x' . repeat ( 1024 * 1024 ) } */\nexport default { fetch() { return new Response("ok"); } };` ,
177+ ) . toString ( 'base64' ) ;
178+ }
179+ const requests : Array < string > = [ ] ;
180+ const userAgents : Array < string | undefined > = [ ] ;
181+ const api = await listen (
182+ createServer ( ( request , response ) => {
183+ requests . push ( request . url ?? '' ) ;
184+ userAgents . push ( request . headers [ 'user-agent' ] ) ;
185+ request . resume ( ) ;
186+ response . writeHead ( 200 , { 'Content-Type' : 'application/json' } ) ;
187+ response . end ( JSON . stringify ( { success : true , errors : [ ] , messages : [ ] , result : draft } ) ) ;
188+ } ) ,
189+ ) ;
190+ const configPath = join ( directory , 'wrangler.json' ) ;
191+ writeFileSync ( configPath , JSON . stringify ( { name : 'test-worker' , account_id : 'test-account' } ) ) ;
192+ const output = await runOperation (
193+ directory ,
194+ {
195+ type : 'versions.view' ,
196+ versionId : draft . id ,
197+ includeSource : true ,
198+ configPath,
199+ workerName : 'test-worker' ,
200+ } ,
201+ { ...tokenEnv ( api ) , CLI_VERSION : 'inherited-version void/stale' } ,
202+ ) ;
203+ expect ( output . status , output . stderr ) . toBe ( 0 ) ;
204+ const result = decodeCloudflareOperationResult ( {
205+ status : 0 ,
206+ stdout : output . stdout ,
207+ stderr : '' ,
208+ } ) ;
209+ expect ( result . status , result . stderr ) . toBe ( 0 ) ;
210+ expect ( result . data ) . toEqual ( draft ) ;
211+ expect ( isVoidSecretOnlyDraft ( result . data as Record < string , unknown > ) ) . toBe ( ! large ) ;
212+ expect ( requests ) . toEqual ( [
213+ `/client/v4/accounts/test-account/workers/workers/test-worker/versions/${ draft . id } ?include=modules` ,
214+ ] ) ;
215+ expect ( output . stdout ) . not . toContain ( 'synthetic-token' ) ;
216+ expect ( userAgents ) . toEqual ( [ `cf-cli/${ cfVersion } void/${ voidVersion } ` ] ) ;
217+ } ,
218+ ) ;
206219
207220it . each ( [ 200 , 503 ] ) (
208221 'reports HTTP %i without loading the build toolchain when domain cleanup returns non-JSON' ,
0 commit comments