Skip to content

Commit

Permalink
set ipv4first dns default result order
Browse files Browse the repository at this point in the history
  • Loading branch information
brenthagen committed Jan 30, 2024
1 parent ed6dc06 commit 2a360ce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app-shell-odd/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// electron main entry point
import { app, ipcMain } from 'electron'
import dns from 'dns'
import fse from 'fs-extra'
import path from 'path'
import { createUi } from './ui'
Expand Down Expand Up @@ -27,6 +28,15 @@ import { registerNotify, closeAllNotifyConnections } from './notify'
import type { BrowserWindow } from 'electron'
import type { Dispatch, Logger } from './types'

/**
* node 17 introduced a change to default IP resolving to prefer IPv6 which causes localhost requests to fail
* setting the default to IPv4 fixes the issue
* https://github.com/node-fetch/node-fetch/issues/1624
*/
// TODO(bh, 2024-1-30): @types/node needs to be updated to address this type error. updating @types/node will also require updating our typescript version
// @ts-expect-error
dns.setDefaultResultOrder('ipv4first')

systemd.sendStatus('starting app')
const config = getConfig()
const log = createLogger('main')
Expand Down
10 changes: 10 additions & 0 deletions app-shell/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// electron main entry point
import { app, ipcMain } from 'electron'
import dns from 'dns'
import contextMenu from 'electron-context-menu'
import { webusb } from 'usb'

Expand All @@ -21,6 +22,15 @@ import { registerNotify, closeAllNotifyConnections } from './notify'
import type { BrowserWindow } from 'electron'
import type { Dispatch, Logger } from './types'

/**
* node 17 introduced a change to default IP resolving to prefer IPv6 which causes localhost requests to fail
* setting the default to IPv4 fixes the issue
* https://github.com/node-fetch/node-fetch/issues/1624
*/
// TODO(bh, 2024-1-30): @types/node needs to be updated to address this type error. updating @types/node will also require updating our typescript version
// @ts-expect-error
dns.setDefaultResultOrder('ipv4first')

const config = getConfig()
const log = createLogger('main')

Expand Down

0 comments on commit 2a360ce

Please sign in to comment.