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 when downloading electron, stating:

dial tcp: lookup on read udp> 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 "": dial tcp: lookup on read udp> read: connection refused*Downloader).follow.func1
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,

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.