Skip to content

Commit ecb5928

Browse files
fix: add timeout to Copilot SDK step to prevent workflow hang
- Add timeout-minutes: 2 to the step level - Wrap SDK call in Promise.race with 60s JS timeout - Falls back to static welcome message instead of hanging indefinitely Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b46eabe commit ecb5928

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

.github/workflows/welcome.yml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ jobs:
104104
105105
- name: Generate welcome message with Copilot
106106
id: personalize
107+
timeout-minutes: 2
107108
env:
108109
GH_TOKEN: ${{ secrets.COPILOT_PAT }}
109110
GUEST_NAME: ${{ steps.parse.outputs.guest_name }}
@@ -144,25 +145,30 @@ jobs:
144145
'',
145146
'Keep it natural and conversational. No emojis. No markdown. Plain text only.'
146147
];
148+
const timeout = new Promise((_, reject) =>
149+
setTimeout(() => reject(new Error('Copilot SDK timed out after 60s')), 60000)
150+
);
147151
try {
148152
const { CopilotClient } = await import('@github/copilot-sdk');
149-
console. log('Initializing Copilot SDK...');
153+
console.log('Initializing Copilot SDK...');
150154
const client = new CopilotClient();
151155
await client.start();
152-
console.log('Creating session.. .');
156+
console.log('Creating session...');
153157
const session = await client.createSession();
154158
const prompt = promptLines.join('\n');
155159
console.log('Sending prompt to Copilot...');
156-
const response = await session. sendAndWait({ prompt: prompt });
157-
if (response && response.data && response.data. content) {
160+
const response = await Promise.race([
161+
session.sendAndWait({ prompt }),
162+
timeout
163+
]);
164+
if (response && response.data && response.data.content) {
158165
personalizedMessage = response.data.content;
159166
console.log('Received personalized message from Copilot');
160167
}
161-
await session. destroy();
168+
await session.destroy();
162169
await client.stop();
163170
} catch (error) {
164-
console.error('Copilot SDK error:', error.message);
165-
console.error('Stack:', error.stack);
171+
console.error('Copilot SDK error (using fallback):', error.message);
166172
}
167173
if (!personalizedMessage) {
168174
console.log('Using fallback message');

0 commit comments

Comments
 (0)