dbus-fd.mjs 711 B

123456789101112131415161718192021
  1. import { createRequire } from "node:module";
  2. const require = createRequire(import.meta.url);
  3. /**
  4. * dbus-next needs the native `usocket` module to receive Unix FDs (OpenPipeWireRemote).
  5. * Without it, Node falls back to net.Socket and FD unmarshalling fails.
  6. * Throws at startup so the user gets a clear error instead of a silent hang.
  7. */
  8. export function assertUsocketAvailable() {
  9. try {
  10. require("usocket");
  11. } catch (err) {
  12. throw new Error(
  13. "The native `usocket` module failed to load. " +
  14. "Wayland screen capture requires it for D-Bus Unix FD passing. " +
  15. "Run `npm rebuild usocket` or reinstall dependencies.\n" +
  16. ` Original error: ${err.message}`,
  17. );
  18. }
  19. }