{"record":{"id":"2f199be1ede4a4b0","repo":"Wei-Shaw/sub2api","slug":"chatgpt-devicecheck-token-generation-timed-out","errorCode":null,"errorMessage":"ChatGPT DeviceCheck token generation timed out","messagePattern":"ChatGPT DeviceCheck token generation timed out","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/internal/platform/liveattestation/attestation_darwin.go","lineNumber":123,"sourceCode":"\tsignalsJSON, err := json.Marshal(signals)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"encode Live attestation signals: %w\", err)\n\t}\n\n\tcommand := exec.CommandContext(runCtx, nodePath, \"-e\", deviceCheckScript)\n\tcommand.Env = []string{\n\t\t\"PATH=/usr/bin:/bin\",\n\t\t\"SUB2API_DEVICECHECK_MODULE=\" + modulePath,\n\t\t\"SUB2API_ATTESTATION_BUNDLE_ID=\" + bundleID,\n\t\t\"SUB2API_ATTESTATION_SIGNALS=\" + string(signalsJSON),\n\t}\n\tvar stdout bytes.Buffer\n\tvar stderr bytes.Buffer\n\tcommand.Stdout = &stdout\n\tcommand.Stderr = &stderr\n\tif err := command.Run(); err != nil {\n\t\tif errors.Is(runCtx.Err(), context.DeadlineExceeded) {\n\t\t\treturn \"\", errors.New(\"ChatGPT DeviceCheck token generation timed out\")\n\t\t}\n\t\treason := strings.TrimSpace(stderr.String())\n\t\tif len(reason) > 240 {\n\t\t\treason = reason[:240]\n\t\t}\n\t\tif reason == \"\" {\n\t\t\treason = err.Error()\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"ChatGPT DeviceCheck token generation failed: %s\", reason)\n\t}\n\theader := strings.TrimSpace(stdout.String())\n\tif len(header) < 20 || len(header) > 16*1024 || !json.Valid([]byte(header)) {\n\t\treturn \"\", errors.New(\"ChatGPT DeviceCheck returned a malformed attestation\")\n\t}\n\treturn header, nil\n}\n\nfunc (p *darwinProvider) findApplication() (string, error) {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/Wei-Shaw/sub2api/blob/073e92d17178a1ccdb0a27017f572f10c9c7ab62/backend/internal/platform/liveattestation/attestation_darwin.go#L105-L141","documentation":"The darwin provider shells out to the ChatGPT app's bundled Node runtime to produce a DeviceCheck token, with a context deadline (attestationTimeout) enforced via command.Run under runCtx. If the child process is killed by the deadline (runCtx.Err() is DeadlineExceeded), this specific timeout error is returned instead of a generic exec failure.","triggerScenarios":"The node subprocess hangs: first-run Gatekeeper prompts, disk pressure, the native module blocking on Keychain access, or system under heavy load such that token generation exceeds attestationTimeout.","commonSituations":"macOS Gatekeeper/first-launch verification of the ChatGPT app binaries; Keychain access prompts waiting for user consent; overloaded or memory-throttled servers; slept/latency-spiking disks.","solutions":["Launch the ChatGPT app once interactively to clear Gatekeeper and Keychain prompts, then retry.","Check system load / memory pressure on the macOS host.","Retry the request; transient subprocess hangs usually clear after the first successful run warms caches.","If timeouts persist, profile the node invocation manually with the documented SUB2API_* env vars to see where it stalls."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"tok, err := provider.Generate(ctx)\nif err != nil && strings.Contains(err.Error(), \"timed out\") {\n    tok, err = provider.Generate(ctx) // first-run Gatekeeper/Keychain warmup is common\n}","preventionTips":["Open the ChatGPT app once interactively to clear Gatekeeper prompts","Monitor load on the macOS host","Warm the attestation path at startup with a dummy Generate"],"tags":["macos","timeout","subprocess","attestation","live"],"backgroundTag":null,"analyzedSha":"073e92d17178a1ccdb0a27017f572f10c9c7ab62","analyzedAt":"2026-08-15T14:33:00.750Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}