@@ -379,37 +379,40 @@ export default class extends BaseViewProvider<typeof ProviderMessageSchema, Webv
379379 const judgeState = ctx . state . find ( ( s ) => s . state === "Judge" ) ! ;
380380
381381 const addCompileTask = ( state : State , filePath : string ) : Promise < CompilationResult > => {
382- return new Promise ( async ( resolve ) => {
383- const compilePromise = compile ( filePath , this . _context ) ;
384- if ( ! compilePromise ) {
385- resolve ( { code : 0 , stdout : "" , stderr : "" } ) ;
386- return ;
387- }
388- if ( this . _currentFile === file ) {
389- super . _postMessage ( {
390- type : "STATUS " ,
391- id : state . state ,
392- status : "COMPILING" ,
393- } ) ;
394- state . stdout . reset ( ) ;
395- state . stderr . reset ( ) ;
396- }
397- const res = await compilePromise ;
398- if ( res . code !== 0 ) {
399- state . status = "CE" ;
400- state . stdout . write ( res . stdout , "final" ) ;
401- state . stderr . write ( res . stderr , "final" ) ;
402- if ( this . _currentFile === file ) {
403- super . _postMessage ( { type : "STATUS" , id : state . state , status : "CE" } ) ;
404- }
405- } else {
406- state . status = "NA" ;
407- if ( this . _currentFile === file ) {
408- super . _postMessage ( { type : "STATUS" , id : state . state , status : "NA" } ) ;
382+ const compilePromise = compile ( filePath , this . _context ) ;
383+ if ( ! compilePromise ) {
384+ return Promise . resolve ( { code : 0 , stdout : "" , stderr : "" } ) ;
385+ }
386+ if ( this . _currentFile === file ) {
387+ super . _postMessage ( {
388+ type : "STATUS" ,
389+ id : state . state ,
390+ status : "COMPILING " ,
391+ } ) ;
392+ state . stdout . reset ( ) ;
393+ state . stderr . reset ( ) ;
394+ }
395+ return compilePromise
396+ . then ( ( res ) => {
397+ if ( res . code !== 0 ) {
398+ state . status = "CE" ;
399+ state . stdout . write ( res . stdout , "final" ) ;
400+ state . stderr . write ( res . stderr , "final" ) ;
401+ if ( this . _currentFile === file ) {
402+ super . _postMessage ( { type : "STATUS" , id : state . state , status : "CE" } ) ;
403+ }
404+ } else {
405+ state . status = "NA" ;
406+ if ( this . _currentFile === file ) {
407+ super . _postMessage ( { type : "STATUS" , id : state . state , status : "NA" } ) ;
408+ }
409409 }
410- }
411- resolve ( res ) ;
412- } ) ;
410+ return res ;
411+ } )
412+ . catch ( ( err ) => {
413+ getLogger ( "stress" ) . error ( `Compile task rejected: ${ err } ` ) ;
414+ return { code : 1 , stdout : "" , stderr : `${ err } ` } ;
415+ } ) ;
413416 } ;
414417
415418 super . _postMessage ( {
0 commit comments