electron-deeplink icon indicating copy to clipboard operation
electron-deeplink copied to clipboard

webpack - DeepLink failing to start

Open FluffyDiscord opened this issue 4 years ago • 19 comments

happening with https://github.com/electron-userland/electron-webpack-quick-start

the process.argv contains following arguments when running yarn dev

  [
    'C:\\wamp64\\www\\ewqp\\electron-webpack-quick-start\\node_modules\\electron\\dist\\electron.exe',
    '--inspect=5858',
    'C:\\wamp64\\www\\ewqp\\electron-webpack-quick-start\\dist\\main\\main.js'
  ]

there are few issues with that, first, you are getting the parameter at index 1 and while the parameter from your example repo is . (local folder), in the webpack-quick-start it's --inspect=5858, this fails setting up the registry key, as it makes it

"C:\wamp64\www\ewqp\electron-webpack-quick-start\node_modules\electron\dist\electron.exe" C:\wamp64\www\ewqp\electron-webpack-quick-start\--inspect=5858 "%1"

instead of

"C:\wamp64\www\ewqp\electron-webpack-quick-start\node_modules\electron\dist\electron.exe" C:\wamp64\www\ewqp\electron-webpack-quick-start\ "%1"

this would be solved, if we could set our path in config, eg.

constructor(config: DeeplinkConfig) {
        super();
        let { app, mainWindow, protocol, isDev = false, debugLogging = false, electronPath = '/node_modules/electron/dist/Electron.app', winPath = null } = config; // here adding another variable

        // if the path is null, trigger default fallback
        if(winPath === null) {
            winPath = [path.resolve(process.argv[1])];
        }
}

then the second issue is (still trying to solve), where I have no idea how do I access running webpack instance and send the link there

build - deeplink wont start image

dev - starts but upon entering the protocol in browser url bar this error is thrown image

let protocol = 'app-dev-enviroment';
const deepLink = new Deeplink({ app, mainWindow, protocol, isDevelopment });
deepLink.on('received', (link) => {
  console.log(link);
});

{
  "name": "electron-webpack-quick-start",
  "version": "0.0.0",
  "license": "MIT",
  "main": "src/main/index.js",
  "scripts": {
    "dev": "electron-webpack dev",
    "compile": "electron-webpack",
    "dist": "yarn compile && electron-builder",
    "dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null",
  },
  "dependencies": {
    "@fortawesome/fontawesome-free": "^5.15.1",
    "autoprefixer": "9.8.0",
    "bootstrap": "^4.5.3",
    "bootstrap-select": "^1.13.18",
    "electron-deeplink": "^1.0.5",
    "fast-xml-parser": "^3.17.5",
    "he": "^1.2.0",
    "jquery": "^3.5.1",
    "micromodal": "^0.4.6",
    "moment": "^2.29.1",
    "popper.js": "^1.16.1",
    "source-map-support": "^0.5.16",
    "tippy.js": "^6.2.7"
  },
  "devDependencies": {
    "@babel/core": "7.0.0",
    "@babel/plugin-proposal-class-properties": "^7.12.1",
    "@babel/preset-env": "^7.12.7",
    "babel-loader": "^8.2.2",
    "electron": "8.2.0",
    "electron-builder": "^22.4.1",
    "electron-store": "^6.0.1",
    "electron-webpack": "^2.8.2",
    "local-cors-proxy": "^1.1.0",
    "node-sass": "^5.0.0",
    "sass-loader": "^10.1.0",
    "webpack": "~4.42.1"
  },
  "electronWebpack": {
    "renderer": {
      "template": "src/renderer/index.html"
    }
  },
  "build": {
    "appId": "mossshine.payzio",
    "win": {
      "target": [
        {
          "target": "portable"
        }
      ]
    },
    "protocols": [
      {
        "name": "Custom Protocol Name",
        "schemes": [
          "app-dev-enviroment"
        ]
      }
    ]
  }
}

regexp key value "C:\wamp64\www\ewqp\electron-webpack-quick-start\node_modules\electron\dist\electron.exe" C:\wamp64\www\ewqp\electron-webpack-quick-start\--inspect=5858 "%1"

FluffyDiscord avatar Dec 10 '20 17:12 FluffyDiscord

We have the same issue! Any fix? Happening on Windows

rlingineni avatar Dec 10 '20 19:12 rlingineni

Looks like this is the culprit, and an arg is being passed here. That arg might not exist in prod.

https://github.com/glawson/electron-deeplink/blob/6fe69245f8d4b77fbcaa6d7e55131d1949489b11/src/index.ts#L115

rlingineni avatar Dec 10 '20 20:12 rlingineni

Looks like this is the culprit, and an arg is being passed here. That arg might not exist in prod.

https://github.com/glawson/electron-deeplink/blob/6fe69245f8d4b77fbcaa6d7e55131d1949489b11/src/index.ts#L115

yes, I updated the post, however I have no idea how do I access the current running webpack instance, so I could pass the value there

FluffyDiscord avatar Dec 10 '20 20:12 FluffyDiscord

I fixed this, but in a mediocore way, and it should be fixed natively in the library.

It looks the only value this library provides over the native commands is a simple wrapper. Primarily, it works on mac in dev mode, and the ability to debug effectively. Outside of that, it seemed to follow the Electron Docs in a fairly standard way.

So I changed it to be like this:

const { Deeplink } =  isDev && isMac ? require("electron-deeplink") : require("./utils/deeplink");

And in my own deeplink file, I copied over the contents, and removed all the Mac Specific things and removed the weird command line args for Windows.

This ended up being broken to our customers, and I had wanted to ship a fix sooner than later. Will fallback to this library once this issue is resolved.

@glawson, is it possible you can make the process args for Windows an arg in the config? Or one of us could open a PR. Thanks a bunch.

rlingineni avatar Dec 10 '20 23:12 rlingineni

@rlingineni @FluffyDiscord - sorry for the late response. Yes, I have time this weekend to do so.

glawson avatar Dec 11 '20 05:12 glawson

@rlingineni or @FluffyDiscord, I have a branch with the fix if you wouldn't mind trying before I publish. npm install https://github.com/glawson/electron-deeplink.git#fixes-uncaught-on-windows

glawson avatar Dec 13 '20 00:12 glawson

@rlingineni or @FluffyDiscord, I have a branch with the fix if you wouldn't mind trying before I publish. npm install https://github.com/glawson/electron-deeplink.git#fixes-uncaught-on-windows

DIST environment now works. The REGEDIT path is set properly. yay

DEV environment is still not working.

Have you tried the "boilerplate" package at https://github.com/electron-userland/electron-webpack-quick-start ? It still fails to set proper path for DEV (electron-webpack dev) and if I try to manually overwrite the REGEDIT key, deeplink then fails to set path again (same issues as before was on DIST, I guess).

Would you mind looking into it ?

Incorrectly set DEV path "C:\wamp64\www\ewqp\electron-webpack-quick-start\node_modules\electron\dist\electron.exe" C:\wamp64\www\ewqp\electron-webpack-quick-start\**--inspect=5858** "%1"

and I think the proper path should be C:\wamp64\www\ewqp\electron-webpack-quick-start\node_modules\electron\dist\electron.exe --inspect=5858 C:\wamp64\www\ewqp\electron-webpack-quick-start\.webpack\main\index.js "%1"

but it fails once again with path not found.

FluffyDiscord avatar Dec 13 '20 12:12 FluffyDiscord

@FluffyDiscord - I didn't get a chance to today, I'll get to it tomorrow evening :)

glawson avatar Dec 14 '20 03:12 glawson

Notes:

C:\Users\geofflawson\Desktop\electron-webpack-quick-start\node_modules\electron\dist\electron.exe --inspect=5858 C:\Users\geofflawson\Desktop\electron-webpack-quick-start\dist\main\main.js

errors with:

[HMR] Env ELECTRON_HMR_SOCKET_PATH is not set

this is from:

https://github.com/electron-userland/electron-webpack/blob/master/packages/electron-webpack/src/electron-main-hmr/main-hmr.ts

electron-webpack dev starts webpack dev server. assuming that this is the dev server socket. with each run it's different:

process.env.ELECTRON_HMR_SOCKET_PATH=/tmp/electron-main-ipc-26a8.sock etc

glawson avatar Dec 16 '20 07:12 glawson

Notes:

C:\Users\geofflawson\Desktop\electron-webpack-quick-start\node_modules\electron\dist\electron.exe --inspect=5858 C:\Users\geofflawson\Desktop\electron-webpack-quick-start\dist\main\main.js

errors with:

[HMR] Env ELECTRON_HMR_SOCKET_PATH is not set

this is from:

https://github.com/electron-userland/electron-webpack/blob/master/packages/electron-webpack/src/electron-main-hmr/main-hmr.ts

electron-webpack dev starts webpack dev server. assuming that this is the dev server socket. with each run it's different:

process.env.ELECTRON_HMR_SOCKET_PATH=/tmp/electron-main-ipc-26a8.sock etc

Then it's impossible for a dev environment to be functional, that's a shame.

FluffyDiscord avatar Dec 16 '20 07:12 FluffyDiscord

@FluffyDiscord - I don't think it's impossible, I just need to figure out their webpack setup for dev. I might need to add an option where you can pass path and args to app.setAsDefaultProtocolClient(protocol[, path, args]) for Windows, and figure out what needs to change in the webpack config. With forge, I had to do a bit of config for dev: https://github.com/glawson/electron-deeplink-example/blob/master/package.json, but it works in dev on windows.

glawson avatar Dec 16 '20 20:12 glawson

@FluffyDiscord - I need to catch up with this. Were you able to move forward?

glawson avatar Apr 21 '21 16:04 glawson

@glawson No, in the end I didn't implement that feature in my personal app, because it was wonky at best eve when the app was build (but I would rather blame windows on it).

FluffyDiscord avatar Apr 21 '21 17:04 FluffyDiscord

Was anyone able to resolve this issue? I am running into the same errors.

Lermatroid avatar Jan 02 '22 10:01 Lermatroid

Was anyone able to resolve this issue? I am running into the same errors.

Yes, I moved away from a webpack as it was adding more and more issues. I am using Rollup now and things work just fine and it's compiling faster than with webpack. Also configuration is way simpler. The boilerplate I am using https://github.com/soulehshaikh99/create-svelte-electron-app you can follow the manual setup go switch existing project. You can skip the Svelte part and use your js framework

FluffyDiscord avatar Jan 02 '22 10:01 FluffyDiscord

@Lermatroid - sorry for the late response, I'm out on vacation right now. I honestly need to re-look into this issue. When @FluffyDiscord updated me last back in 4/21 I was neck deep into another project and this became very back burner and dropped off my radar. I'll be back at it next week, the goal will be to make sure it's working with webpack. I'll update you soon.

glawson avatar Jan 02 '22 19:01 glawson

All good, enjoy your vacation! Excited to see future updates and thanks for the awesome library!

Lermatroid avatar Jan 03 '22 16:01 Lermatroid

I'm curious if you've had any discoveries on this?

elincoln avatar Aug 21 '22 21:08 elincoln

Yeah, macos LaunchServices has changed a bunch, and node-gyp is out of date in this repo. I'm in the process of a v2 right now to deal with these changes.

glawson avatar Aug 24 '22 16:08 glawson

https://github.com/glawson/electron-deeplink#-deprecation-notice-

glawson avatar Aug 18 '23 15:08 glawson