jeffbski / wait-on

wait-on is a cross-platform command line utility and Node.js API which will wait for files, ports, sockets, and http(s) resources to become available
MIT License
1.87k stars 77 forks source link

TypeError: The "original" argument must be of type Function #76

Closed nixis closed 4 years ago

nixis commented 4 years ago

Hi there,

I want to use wait-on in a Electron with Vue application.

Do I use wait-on on the right track?

If I run the app, I get an error on the Electron browser console.

If I don't use wait-on in the code, the app starts normally without errors.

I googled a while, but I found no solution.

Error message:

[HMR] Waiting for update signal from WDS...
webpack-internal:///./node_modules/util/util.js:602 Uncaught TypeError: The "original" argument must be of type Function
    at promisify (webpack-internal:///./node_modules/util/util.js:602)
    at Object.eval (webpack-internal:///./node_modules/wait-on/lib/wait-on.js:20)
    at eval (webpack-internal:///./node_modules/wait-on/lib/wait-on.js:399)
    at Object../node_modules/wait-on/lib/wait-on.js (chunk-vendors.js:12379)
    at __webpack_require__ (app.js:849)
    at fn (app.js:151)
    at eval (webpack-internal:///./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/App.vue?vue&type=script&lang=js&:2)
    at Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/App.vue?vue&type=script&lang=js& (app.js:938)
    at __webpack_require__ (app.js:849)
    at fn (app.js:151)

Node, NPM, Yarn:

node -v
v12.14.1
npm -v    
6.13.4
yarn -v           
1.15.2

package.json

{
  "name": "test-gui",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve --host localhost",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "electron:build": "vue-cli-service electron:build",
    "electron:serve": "vue-cli-service electron:serve",
    "postinstall": "electron-builder install-app-deps",
    "postuninstall": "electron-builder install-app-deps"
  },
  "main": "background.js",
  "dependencies": {
    "core-js": "^3.6.5",
    "vue": "^2.6.11",
    "vuetify": "^2.3.8",
    "wait-on": "^5.2.0"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "babel-eslint": "^10.1.0",
    "electron": "^9.0.0",
    "electron-devtools-installer": "^3.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^6.2.2",
    "sass": "^1.19.0",
    "sass-loader": "^8.0.0",
    "vue-cli-plugin-electron-builder": "~2.0.0-rc.4",
    "vue-cli-plugin-vuetify": "~2.0.7",
    "vue-template-compiler": "^2.6.11",
    "vuetify-loader": "^1.3.0"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

App.vue

<template>
  <v-app>

    <v-main>
      <p>Test</p>
<!--      component -->
    </v-main>
  </v-app>
</template>

<script>
import waitOn from 'wait-on';

export default {
  name: 'App',

  components: {
  },

  created() {
    var opts = {
      resources: [
        'https-get://google.de',
      ],
    };
    // Usage with callback function
    waitOn(opts, function (err) {
      if (err) {
        console.log(err);
      }
      // once here, all resources are available
    });
  },

  methods: {

  },

  data: () => ({
    //
  }),
};
</script>

Steps to reproduce:

vue create my-app
cd my-app
vue add vuetify
vue add electron-builder
yarn electron:serve

Same error on Windows and MacOS