(request: CompilationRequest)
| 468 | } |
| 469 | |
| 470 | sendCompile(request: CompilationRequest): void { |
| 471 | const onCompilerResponse = this.onCompileResponse.bind(this); |
| 472 | |
| 473 | if (this.pendingRequestSentAt) { |
| 474 | // If we have a request pending, then just store this request to do once the |
| 475 | // previous request completes. |
| 476 | this.nextRequest = request; |
| 477 | return; |
| 478 | } |
| 479 | // this.eventHub.emit('compiling', this.id, this.compiler); |
| 480 | // Display the spinner |
| 481 | this.handleCompilationStatus({code: 4}); |
| 482 | this.pendingRequestSentAt = Date.now(); |
| 483 | // After a short delay, give the user some indication that we're working on their |
| 484 | // compilation. |
| 485 | this.hub.compilerService |
| 486 | .submit(request) |
| 487 | .then((x: any) => { |
| 488 | onCompilerResponse(request, x.result, x.localCacheHit); |
| 489 | }) |
| 490 | .catch(x => { |
| 491 | let message = 'Unknown error'; |
| 492 | const isNetworkError = (x as any)?.isNetworkError === true; |
| 493 | if (typeof x === 'string') { |
| 494 | message = x; |
| 495 | } else if (x) { |
| 496 | message = x.error || x.code || x.message || x; |
| 497 | } |
| 498 | const result = isNetworkError |
| 499 | ? {...this.errorResult(message), networkError: true} |
| 500 | : this.errorResult(message); |
| 501 | onCompilerResponse(request, result, false); |
| 502 | }); |
| 503 | } |
| 504 | |
| 505 | addCompilerOutputLine( |
| 506 | msg: string, |
no test coverage detected