File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -59,6 +59,7 @@ typings/
5959
6060# Optional npm cache directory
6161.npm
62+ .bun
6263
6364# Optional eslint cache
6465.eslintcache
112113
113114# TernJS port file
114115.tern-port
116+
117+ # Bun lock
118+ bun.lock
119+ bun.lockb
Original file line number Diff line number Diff line change @@ -91,6 +91,7 @@ export default class REST implements IApi {
9191 if ( requestToken ) this . rateLimiter . verify ( requestToken ) ;
9292
9393 const isReadonly = ! config . method || config . method === RequestMethod . Get ;
94+ const hasBody = config . method === RequestMethod . Post || config . method === RequestMethod . Put ;
9495 const retries = isReadonly ? MAX_RETRIES : 1 ;
9596
9697 let lastError : unknown ;
@@ -102,11 +103,11 @@ export default class REST implements IApi {
102103 await sleep ( delay ) ;
103104 }
104105
105- const controller = new AbortController ( ) ;
106- const timeout = setTimeout ( ( ) => controller . abort ( ) , REQUEST_TIMEOUT_MS ) ;
106+ const controller = hasBody ? null : new AbortController ( ) ;
107+ const timeout = controller ? setTimeout ( ( ) => controller . abort ( ) , REQUEST_TIMEOUT_MS ) : null ;
107108
108109 try {
109- const response = await fetch ( url , { ...config , signal : controller . signal } ) ;
110+ const response = await fetch ( url , { ...config , ... ( controller ? { signal : controller . signal } : { } ) } ) ;
110111
111112 if ( requestToken ) this . #handleResponseHeaders( response . headers , requestToken ) ;
112113
@@ -138,7 +139,7 @@ export default class REST implements IApi {
138139 if ( attempt < retries - 1 ) continue ;
139140 throw err ;
140141 } finally {
141- clearTimeout ( timeout ) ;
142+ if ( timeout ) clearTimeout ( timeout ) ;
142143 }
143144 }
144145
You can’t perform that action at this time.
0 commit comments