@@ -204,6 +204,11 @@ export async function queryMemoryTableRows({
204204 getMaxPageBytes ( ) ?? TABLE_LIMITS . MAX_QUERY_RESULT_BYTES ,
205205 TABLE_LIMITS . MAX_QUERY_RESULT_BYTES
206206 )
207+ const omittedTranscript : JsonValue = {
208+ omitted : true ,
209+ reason : `Transcript exceeds the ${ Math . floor ( pageByteBudget / ( 1024 * 1024 ) ) } MB table query limit` ,
210+ }
211+ const oversizedTranscriptIds = new Set < string > ( )
207212 const selectedCandidates : typeof candidates = [ ]
208213 let selectedBytes = 0
209214 let hasMore = candidates . length === limit
@@ -213,21 +218,24 @@ export async function queryMemoryTableRows({
213218 if ( ! Number . isFinite ( rowBytes ) || rowBytes < 0 ) {
214219 throw new TableQueryValidationError ( 'Memory table returned an invalid row size' )
215220 }
221+ let outputRowBytes = rowBytes
216222 if ( rowBytes > pageByteBudget ) {
217- throw new TableQueryValidationError (
218- `Memory transcript exceeds the ${ Math . floor ( pageByteBudget / ( 1024 * 1024 ) ) } MB table query limit` ,
219- 'TABLE_QUERY_RESULT_TOO_LARGE'
223+ oversizedTranscriptIds . add ( candidate . id )
224+ outputRowBytes = Buffer . byteLength (
225+ JSON . stringify ( mapMemoryRecordToTableRow ( { ... candidate , data : omittedTranscript } ) . data )
220226 )
221227 }
222- if ( selectedCandidates . length > 0 && selectedBytes + rowBytes > pageByteBudget ) {
228+ if ( selectedCandidates . length > 0 && selectedBytes + outputRowBytes > pageByteBudget ) {
223229 hasMore = true
224230 break
225231 }
226232 selectedCandidates . push ( candidate )
227- selectedBytes += rowBytes
233+ selectedBytes += outputRowBytes
228234 }
229235
230- const selectedIds = selectedCandidates . map ( ( candidate ) => candidate . id )
236+ const selectedIds = selectedCandidates
237+ . filter ( ( candidate ) => ! oversizedTranscriptIds . has ( candidate . id ) )
238+ . map ( ( candidate ) => candidate . id )
231239 const transcripts =
232240 selectedIds . length > 0
233241 ? await db
@@ -244,7 +252,9 @@ export async function queryMemoryTableRows({
244252 : [ ]
245253 const transcriptById = new Map ( transcripts . map ( ( record ) => [ record . id , record . data ] ) )
246254 const rows = selectedCandidates . flatMap ( ( candidate , index ) => {
247- const transcript = transcriptById . get ( candidate . id )
255+ const transcript = oversizedTranscriptIds . has ( candidate . id )
256+ ? omittedTranscript
257+ : transcriptById . get ( candidate . id )
248258 if ( transcript === undefined ) return [ ]
249259 return [
250260 mapMemoryRecordToTableRow (
0 commit comments