Failed DNS lookup in javascript build script

Hi everyone. I’m very new to Flatpack packaging. I’m recently packaging an electron app. Following the tutorial here, I got most issues sorted out except one thing: the build.js script of my specific electron app project fails in the build process.

The electron app I’m packaging does not call electron-builder through CLI. It use its own build script to prepare its own source code (in TypeScript) before invoking electron-builder.

The build.js script can be executed normally in my host environment. But when I run it through flatpak-builder, the script fails to resolve github.com when downloading electron, stating:

dial tcp: lookup github.com on 127.0.0.53:53: read udp 127.0.0.1:60792->127.0.0.53:53: read: connection refused
A longer version of the messages
$ flatpak-builder build com.gitlab.zerkc.WhatsDesk.yml --install --force-clean --user
...
...
npm info it worked if it ends with ok
npm info using npm@6.14.16
npm info using node@v14.19.0
npm info lifecycle whatsdesk@0.3.8~pretsc: whatsdesk@0.3.8
npm info lifecycle whatsdesk@0.3.8~tsc: whatsdesk@0.3.8
npm info lifecycle whatsdesk@0.3.8~posttsc: whatsdesk@0.3.8
npm timing npm Completed in 1508ms
npm info ok 
  • electron-builder  version=22.14.13 os=5.16.12-200.fc35.x86_64
  • loaded configuration  file=package.json ("build" field)
  • writing effective config  file=dist/builder-effective-config.yaml
  • packaging       platform=linux arch=ia32 electron=15.4.1 appOutDir=dist/linux-ia32-unpacked
  ⨯ Get "https://github.com/electron/electron/releases/download/v15.4.1/electron-v15.4.1-linux-ia32.zip": dial tcp: lookup github.com on 127.0.0.53:53: read udp 127.0.0.1:60792->127.0.0.53:53: read: connection refused
github.com/develar/app-builder/pkg/download.(*Downloader).follow.func1
	/Volumes/data/Documents/app-builder/pkg/download/downloader.go:206
github.com/develar/app-builder/pkg/download.(*Downloader).follow
	/Volumes/data/Documents/app-builder/pkg/download/downloader.go:234
github.com/develar/app-builder/pkg/download.(*Downloader).DownloadNoRetry
	/Volumes/data/Documents/app-builder/pkg/download/downloader.go:128
github.com/develar/app-builder/pkg/download.(*Downloader).Download
	/Volumes/data/Documents/app-builder/pkg/download/downloader.go:112
github.com/develar/app-builder/pkg/electron.(*ElectronDownloader).doDownload
	/Volumes/data/Documents/app-builder/pkg/electron/electronDownloader.go:192
github.com/develar/app-builder/pkg/electron.(*ElectronDownloader).Download
	/Volumes/data/Documents/app-builder/pkg/electron/electronDownloader.go:177
github.com/develar/app-builder/pkg/electron.downloadElectron.func1.1
	/Volumes/data/Documents/app-builder/pkg/electron/electronDownloader.go:73
github.com/develar/app-builder/pkg/util.MapAsyncConcurrency.func2
	/Volumes/data/Documents/app-builder/pkg/util/async.go:68
runtime.goexit
	/usr/local/Cellar/go/1.16.5/libexec/src/runtime/asm_amd64.s:1371  
ExecError: /run/build/whatsdesk-app/main/node_modules/app-builder-bin/linux/x64/app-builder exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
    at ChildProcess.<anonymous> (/run/build/whatsdesk-app/main/node_modules/builder-util/src/util.ts:250:14)
    at Object.onceWrapper (events.js:520:26)
    at ChildProcess.emit (events.js:400:28)
    at maybeClose (internal/child_process.js:1058:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5) {
  exitCode: 1,
  alreadyLogged: false,
  code: 'ERR_ELECTRON_BUILDER_CANNOT_EXECUTE'
}

Seems the building process is sandboxed in a way that DNS is not accessible. Is there any way I can fix the build process so it works?

you don’t have access to the network during the build. Any package that needs to be downloaded should be listed as a “source”

for electron / node there is a flatpak-builder-tools that allow generating such a manifest.