File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,8 @@ import {
4848import { Uploader } from '../uploader/uploader' ;
4949import { Artifact , SsorAttachment } from '../uploader/uploader.interfaces' ;
5050
51+ const MAX_MESSAGE_LENGTH : number = 200_000 ;
52+
5153export function createWorkerAdapter < ConnectorState > ( {
5254 event,
5355 adapterState,
@@ -91,6 +93,9 @@ export class WorkerAdapter<ConnectorState> {
9193 private _mappers : Mappers ;
9294 private uploader : Uploader ;
9395
96+ // Length of the resulting artifact JSON object string.
97+ private currentLength : number = 0 ;
98+
9499 constructor ( {
95100 event,
96101 adapterState,
@@ -149,12 +154,20 @@ export class WorkerAdapter<ConnectorState> {
149154 itemType : repo . itemType ,
150155 ...( shouldNormalize && { normalize : repo . normalize } ) ,
151156 onUpload : ( artifact : Artifact ) => {
157+ let newLength = JSON . stringify ( artifact ) . length ;
158+
152159 // We need to store artifacts ids in state for later use when streaming attachments
153160 if ( repo . itemType === AIRDROP_DEFAULT_ITEM_TYPES . ATTACHMENTS ) {
154161 this . state . toDevRev ?. attachmentsMetadata . artifactIds . push (
155162 artifact . id
156163 ) ;
157164 }
165+
166+ if ( this . currentLength + newLength > MAX_MESSAGE_LENGTH ) {
167+ // TODO: We need to call the adapter's `onTimeout` here and `emit` the Progress event.
168+ // We might have to run the `uploadAllRepos` as well.
169+ this . handleTimeout ( ) ;
170+ }
158171 } ,
159172 options : this . options ,
160173 } ) ;
You can’t perform that action at this time.
0 commit comments