File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export interface LocalTimingInfo {
2020
2121/** Format bytes into a human-readable string. */
2222export function formatBytes ( n : number ) : string {
23+ if ( ! Number . isFinite ( n ) || n < 0 ) return "0B" ;
2324 if ( n === 0 ) return "0B" ;
2425 if ( n < 1024 ) return `${ n } B` ;
2526 if ( n < 1024 * 1024 ) return `${ ( n / 1024 ) . toFixed ( n < 10240 ? 1 : 0 ) } KB` ;
Original file line number Diff line number Diff line change 11import type { Row } from "./types.js" ;
22import { encodeColumnarRun , decodeColumnarRun } from "./r2-spill.js" ;
3+ import { QueryModeError } from "./errors.js" ;
34
45/** A partition of data stored in R2 */
56export interface R2Partition {
@@ -21,6 +22,7 @@ export class R2Partitioner {
2122 private partitionBytesWritten : number [ ] ;
2223
2324 constructor ( bucket : R2Bucket , prefix : string , partitionCount : number ) {
25+ if ( partitionCount < 1 ) throw new QueryModeError ( "QUERY_FAILED" , "R2Partitioner: partitionCount must be >= 1" ) ;
2426 this . bucket = bucket ;
2527 this . prefix = prefix ;
2628 this . partitionCount = partitionCount ;
@@ -115,7 +117,9 @@ export class WorkerPool {
115117 } ) {
116118 this . bucket = opts . bucket ;
117119 this . doNamespace = opts . doNamespace ;
118- this . maxFanOut = opts . maxFanOut ?? 50 ;
120+ const fanOut = opts . maxFanOut ?? 50 ;
121+ if ( fanOut < 1 ) throw new QueryModeError ( "QUERY_FAILED" , "WorkerPool: maxFanOut must be >= 1" ) ;
122+ this . maxFanOut = fanOut ;
119123 }
120124
121125 /**
You can’t perform that action at this time.
0 commit comments