Skip to content

Commit

Permalink
fix: signal not working without node-fetch
Browse files Browse the repository at this point in the history
Signed-off-by: Avior <[email protected]>
  • Loading branch information
Aviortheking committed May 7, 2024
1 parent d939144 commit f70ea19
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Binary file modified server/bun.lockb
Binary file not shown.
12 changes: 9 additions & 3 deletions server/compiler/utils/util.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Card, Set } from '../../../interfaces'
import { glob } from 'glob'
import fetch from 'node-fetch'
import { Card, Set } from '../../../interfaces'
import * as legals from '../../../meta/legals'

interface fileCacheInterface {
Expand All @@ -18,9 +17,16 @@ const fileCache: fileCacheInterface = {}
*/
export async function fetchRemoteFile<T = any>(url: string): Promise<T> {
if (!fileCache[url]) {
const signal = new AbortController()

const finished = setTimeout(() => {
signal.abort()
}, 60 * 1000);

const resp = await fetch(url, {
timeout: 60 * 1000
signal: signal.signal
})
clearTimeout(finished)
fileCache[url] = resp.json()
}
return fileCache[url]
Expand Down
1 change: 0 additions & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"@types/express": "^4",
"@types/node": "^20",
"glob": "^10",
"node-fetch": "^3",
"ts-node": "^10",
"ts-node-dev": "^2",
"typescript": "^5"
Expand Down

0 comments on commit f70ea19

Please sign in to comment.