@@ -51,9 +51,7 @@ let web: WebClient;
51
51
*/
52
52
const initializeWeb = ( ) : WebClient => {
53
53
if ( ! web ) {
54
- web = new WebClient ( E2E_SLACK_TOKEN , {
55
- timeout : 10000 , // 10 second timeout to prevent hanging
56
- } ) ;
54
+ web = new WebClient ( E2E_SLACK_TOKEN ) ;
57
55
}
58
56
return web ;
59
57
} ;
@@ -115,45 +113,27 @@ export const sendFailedTestMessageToSlack = async ( testName: string ) => {
115
113
const { branch, commit, webUrl } = slackParams ;
116
114
const webClient = initializeWeb ( ) ;
117
115
118
- // Add timeout to prevent hanging
119
- const timeoutPromise = new Promise ( ( _ , reject ) => {
120
- setTimeout ( ( ) => reject ( new Error ( 'Slack API timeout' ) ) , 10000 ) ;
121
- } ) ;
122
-
123
116
try {
124
117
// Adding the app does not add the app user to the channel
125
- await Promise . race ( [
126
- webClient . conversations . join ( {
127
- channel : E2E_SLACK_CHANNEL_ID ,
128
- token : E2E_SLACK_TOKEN ,
129
- } ) ,
130
- timeoutPromise ,
131
- ] ) ;
118
+ await webClient . conversations . join ( {
119
+ channel : E2E_SLACK_CHANNEL_ID ,
120
+ token : E2E_SLACK_TOKEN ,
121
+ } ) ;
132
122
} catch ( error ) {
133
- // Handle the case where the bot is already in the channel
134
- if ( ( error as CodedError ) . code === 'already_in_channel' ) {
135
- // This is expected and not an error - the bot is already in the channel
136
- console . log ( 'Bot is already in the Slack channel' ) ;
137
- } else {
138
- handleRequestError ( error , 'Failed to join the channel' ) ;
139
- return ; // Don't proceed if we can't join the channel
140
- }
123
+ handleRequestError ( error , 'Failed to join the channel' ) ;
141
124
}
142
125
143
126
try {
144
- await Promise . race ( [
145
- webClient . chat . postMessage ( {
146
- channel : E2E_SLACK_CHANNEL_ID ,
147
- token : E2E_SLACK_TOKEN ,
148
- text : `Test failed on *${ branch } * branch. \n
127
+ await webClient . chat . postMessage ( {
128
+ channel : E2E_SLACK_CHANNEL_ID ,
129
+ token : E2E_SLACK_TOKEN ,
130
+ text : `Test failed on *${ branch } * branch. \n
149
131
The commit this build is testing is *${ commit } *. \n
150
132
The name of the test that failed: *${ testName } *. \n
151
133
See screenshot of the failed test below. ${
152
134
webUrl ? `*Build log* can be found here: ${ webUrl } ` : ''
153
135
} `,
154
- } ) ,
155
- timeoutPromise ,
156
- ] ) ;
136
+ } ) ;
157
137
} catch ( error ) {
158
138
handleRequestError ( error , 'Failed to post message to Slack' ) ;
159
139
}
@@ -173,21 +153,13 @@ export const sendFailedTestScreenshotToSlack = async (
173
153
const filename = `screenshot_of_${ testName || 'failed_test' } .png` ;
174
154
const webClient = initializeWeb ( ) ;
175
155
176
- // Add timeout to prevent hanging
177
- const timeoutPromise = new Promise ( ( _ , reject ) => {
178
- setTimeout ( ( ) => reject ( new Error ( 'Slack API timeout' ) ) , 15000 ) ;
179
- } ) ;
180
-
181
156
try {
182
- await Promise . race ( [
183
- webClient . filesUploadV2 ( {
184
- filename,
185
- file : createReadStream ( screenshotOfFailedTest ) ,
186
- token : E2E_SLACK_TOKEN ,
187
- channel_id : E2E_SLACK_CHANNEL_ID ,
188
- } ) ,
189
- timeoutPromise ,
190
- ] ) ;
157
+ await webClient . filesUploadV2 ( {
158
+ filename,
159
+ file : createReadStream ( screenshotOfFailedTest ) ,
160
+ token : E2E_SLACK_TOKEN ,
161
+ channel_id : E2E_SLACK_CHANNEL_ID ,
162
+ } ) ;
191
163
} catch ( error ) {
192
164
handleRequestError ( error , 'Failed to upload screenshot to Slack' ) ;
193
165
}
0 commit comments