File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5959 "@sapphire/async-queue" : " ^1.5.5" ,
6060 "@vladfrangu/async_event_emitter" : " ^2.4.6" ,
6161 "csv-stringify" : " ^6.5.2" ,
62- "fs-extra" : " ^11.3.0" ,
6362 "json5" : " ^2.2.3" ,
6463 "minimatch" : " ^10.0.1" ,
6564 "ow" : " ^2.0.0" ,
Original file line number Diff line number Diff line change @@ -264,14 +264,16 @@ export class Configuration {
264264 }
265265
266266 /**
267- * Reads the first non-empty env var value for a field definition.
267+ * Reads the first defined env var value for a field definition.
268+ * Empty strings are passed through — schema coercion handles them
269+ * (e.g. `coerceBoolean` treats `''` as `false`).
268270 */
269271 private static readEnvVar ( fieldDef : ConfigField ) : string | undefined {
270272 if ( ! fieldDef . envVar ) return undefined ;
271273 const envVars = Array . isArray ( fieldDef . envVar ) ? fieldDef . envVar : [ fieldDef . envVar ] ;
272274 for ( const envVar of envVars ) {
273275 const value = process . env [ envVar ] ;
274- if ( value != null && value !== '' ) return value ;
276+ if ( value != null ) return value ;
275277 }
276278 return undefined ;
277279 }
Original file line number Diff line number Diff line change @@ -106,6 +106,22 @@ describe('Configuration', () => {
106106 expect ( new Configuration ( ) . headless ) . toBe ( true ) ;
107107 } ) ;
108108
109+ it ( 'treats empty-string boolean env var as false' , ( ) => {
110+ setEnv ( 'CRAWLEE_HEADLESS' , '' ) ;
111+ expect ( new Configuration ( ) . headless ) . toBe ( false ) ;
112+
113+ setEnv ( 'CRAWLEE_PURGE_ON_START' , '' ) ;
114+ expect ( new Configuration ( ) . purgeOnStart ) . toBe ( false ) ;
115+ } ) ;
116+
117+ it ( 'coerces empty-string number env var to 0' , ( ) => {
118+ setEnv ( 'CRAWLEE_PERSIST_STATE_INTERVAL_MILLIS' , '' ) ;
119+ expect ( new Configuration ( ) . persistStateIntervalMillis ) . toBe ( 0 ) ;
120+
121+ setEnv ( 'CRAWLEE_MEMORY_MBYTES' , '' ) ;
122+ expect ( new Configuration ( ) . memoryMbytes ) . toBe ( 0 ) ;
123+ } ) ;
124+
109125 it ( 'coerces number env vars' , ( ) => {
110126 setEnv ( 'CRAWLEE_PERSIST_STATE_INTERVAL_MILLIS' , '30000' ) ;
111127 expect ( new Configuration ( ) . persistStateIntervalMillis ) . toBe ( 30_000 ) ;
Original file line number Diff line number Diff line change @@ -961,7 +961,6 @@ __metadata:
961961 "@sapphire/async-queue": "npm:^1.5.5"
962962 "@vladfrangu/async_event_emitter": "npm:^2.4.6"
963963 csv-stringify: "npm:^6.5.2"
964- fs-extra: "npm:^11.3.0"
965964 json5: "npm:^2.2.3"
966965 minimatch: "npm:^10.0.1"
967966 ow: "npm:^2.0.0"
@@ -15922,16 +15921,9 @@ __metadata:
1592215921 languageName: node
1592315922 linkType: hard
1592415923
15925- "zod@npm:^3.24.0 || ^4.0.0":
15924+ "zod@npm:^3.24.0 || ^4.0.0, zod@npm:^3.25 || ^4.0, zod@npm:^4.3.5 ":
1592615925 version: 4.3.6
1592715926 resolution: "zod@npm:4.3.6"
1592815927 checksum: 10c0/860d25a81ab41d33aa25f8d0d07b091a04acb426e605f396227a796e9e800c44723ed96d0f53a512b57be3d1520f45bf69c0cb3b378a232a00787a2609625307
1592915928 languageName: node
1593015929 linkType: hard
15931-
15932- "zod@npm:^3.25 || ^4.0, zod@npm:^4.3.5":
15933- version: 4.3.5
15934- resolution: "zod@npm:4.3.5"
15935- checksum: 10c0/5a2db7e59177a3d7e202543f5136cb87b97b047b77c8a3d824098d3fa8b80d3aa40a0a5f296965c3b82dfdccdd05dbbfacce91347f16a39c675680fd7b1ab109
15936- languageName: node
15937- linkType: hard
You can’t perform that action at this time.
0 commit comments