(req: Request)
| 33 | ) {} |
| 34 | |
| 35 | async handleFetch(req: Request): Promise<Response> { |
| 36 | const [state, versions, idle] = await Promise.all([ |
| 37 | this.driver.debugState(), |
| 38 | this.driver.debugVersions(), |
| 39 | this.driver.debugIdleState(), |
| 40 | ]); |
| 41 | |
| 42 | const msgState = `NGSW Debug Info: |
| 43 | |
| 44 | Driver version: ${SW_VERSION} |
| 45 | Driver state: ${state.state} (${state.why}) |
| 46 | Latest manifest hash: ${state.latestHash || 'none'} |
| 47 | Last update check: ${this.since(state.lastUpdateCheck)}`; |
| 48 | |
| 49 | const msgVersions = versions |
| 50 | .map( |
| 51 | (version) => `=== Version ${version.hash} === |
| 52 | |
| 53 | Clients: ${version.clients.join(', ')}`, |
| 54 | ) |
| 55 | .join('\n\n'); |
| 56 | |
| 57 | const msgIdle = `=== Idle Task Queue === |
| 58 | Last update tick: ${this.since(idle.lastTrigger)} |
| 59 | Last update run: ${this.since(idle.lastRun)} |
| 60 | Task queue: |
| 61 | ${idle.queue.map((v) => ' * ' + v).join('\n')} |
| 62 | |
| 63 | Debug log: |
| 64 | ${this.formatDebugLog(this.debugLogB)} |
| 65 | ${this.formatDebugLog(this.debugLogA)} |
| 66 | `; |
| 67 | |
| 68 | return this.adapter.newResponse( |
| 69 | `${msgState} |
| 70 | |
| 71 | ${msgVersions} |
| 72 | |
| 73 | ${msgIdle}`, |
| 74 | {headers: this.adapter.newHeaders({'Content-Type': 'text/plain'})}, |
| 75 | ); |
| 76 | } |
| 77 | |
| 78 | since(time: number | null): string { |
| 79 | if (time === null) { |
nothing calls this directly
no test coverage detected