(Please answer all 3)
TypeError: Third argument must be a function
at internal/util.js:297:30
at new Promise (<anonymous>)
at open (internal/util.js:296:12)
at WindowsBinding.open (C:\Users\user\wwsu-dj-controls\node_modules\@serialport\bindings\lib\win32.js:56:22)
at processTicksAndRejections (internal/process/task_queues.js:97:5)// let device = device path retrieved from electron.settings, which I verified is operating correctly.
delaySerial = new serialport(device, {
baudRate: 38400,
});
delaySerial.on("error", (err) => {
serialError(err); // function sends the error both to the console and another logging utility. It also disconnects the serialport if not already disconnected and attempts to reconnect after a 15 second delay.
});
@Lovinity Encountered same problem. This problem was not found in [email protected] + electron@8 though.
Just for reference (this isn't really a solution, of course, if anything, it's an ugly hack): After encountering the same error, I was able to get it to work with Electron 11.1.0 and serialport in version 8.0.8 (after running electron-rebuild, of course) on both Windows and Linux.
Seeing
@Lovinity Encountered same problem. This problem was not found in [email protected] + electron@8 though.
might, of course, mean, that a downgrade to an exact 9.0.3 might also have solved that problem, of course (I probably didn't properly specify the exact version, which has then lead me to believe 9.0.3 wasn't working either 😅 ).
@pklaschka That's true it's a dirty solution. I unfortunately cannot rely on rebuild and must use prebuilt binaries due to limitations with concurrent jobs in the build tool I use (if I use matrices, not only does that drastically complicate things, but it might cost money too; so I have to build for all OSes on MacOS. And rebuild will only work for the MacOS build on MacOS).
@pklaschka so you're saying the prebuilds for windows in v9.0.4 have an issue but if you rebuild them they work for you?
@pklaschka so you're saying the prebuilds for windows in v9.0.4 have an issue but if you rebuild them they work for you?
No. With 9.0.4, the "Third argument must be a function" error occurs either way (also after rebuilding). I just mentioned electron-rebuild to make it clear that, to use Electron 11, I had rebuilt the older (!) version of serialport with success. Sorry if that wasn't clear 😉
That's frustrating, nothing about the serialport code has changed between those versions.
Maybe a dependency update is breaking the build?
Yeah, probably Nan which was required to build for the latest electron
https://github.com/serialport/node-serialport/blob/master/packages/bindings/src/serialport_win.cpp#L314-L317 is probably the code you're hitting. It's the write callback, which is guaranteed to have a callback here https://github.com/serialport/node-serialport/blob/master/packages/bindings/lib/win32.js#L10
I'll take a peak at some of the build warnings from the c++, maybe they've changed how functions work or something.
Same problem
Same problem here. It used to work fine, and then I started playing around with electron-rebuild and called it a number of times. Now I get this exact same error. Sorry this is vague, I can't really give any more details about it.
EDIT: O.K. I have more details:
COM port works fine in commit https://github.com/gbmhunter/ninjaterm-electron/commit/a02b89185891d9234b26c4473759231879581f2a
COM port does not work in commit https://github.com/gbmhunter/ninjaterm-electron/commit/69bd384161defe672378a1520314710c1abc3960
Wait, it now works in https://github.com/gbmhunter/ninjaterm-electron/commit/69bd384161defe672378a1520314710c1abc3960, after I re-ran yarn install. Ignore the two works/does not works commit, something more complex is going on.
I encountered same problem, too and I found the reason that cause this issue.
I used Electron 11.1, @serialport/bindings 9.0.4 (with serialport 9.0.4), electron-builder 22.9.1.
The reason what occurs this issue is wrong prebuilt image of @serialport/[email protected].
By default, electron-builder using prebuilt image if exists. And there was a prebuilt image of @serialport/bindings.
When I run the application after electron-rebuild was successfully working [email protected] with @serialport/[email protected].
But after run the electron-builder, this issue reproduced with no code changes.
And I looked into the logs of electron-builder, it uses prebuilt image of @serialport/bindings.
So I add the option to force rebuild dependencies to the electron-builder option shots the problem.
"build": {
...
"buildDependenciesFromSource": true,
...
}
Packing time was slightly slowed-down but it was my best solution to using the latest version of serialport.
Well... that's promising, it means a problem with the build vs the source. I removed the existing builds and forced another one can you try it again?
Well... that's promising, it means a problem with the build vs the source. I removed the existing builds and forced another one can you try it again?
Tried with the latest built binding (bindings-v9.0.4-electron-v85-win32-x64), the "TypeError: Third argument must be a function" error still occurs.
Tried to run electron-rebuild for serialport module, also failed #2194
um, work for me change electron version to 10.1.3。 demo here
Well... that's promising, it means a problem with the build vs the source. I removed the existing builds and forced another one can you try it again?
I just got a same result as @orange-beans after flush the npm cache.
• install prebuilt binary name=@serialport/bindings version=9.0.4 platform=win32 arch=x64
• execute command command='{nodejs}\node.exe' '{Project}\node_modules\prebuild-install\bin.js' --platform=win32 --arch=x64 --target=11.1.1 --runtime=electron --verbose --force
workingDirectory={Project}\node_modules\@serialport\bindings
• command executed executable={nodejs}\node.exe
errorOut=prebuild-install info begin Prebuild-install version 6.0.0
prebuild-install WARN install prebuilt binaries enforced with --force!
prebuild-install WARN install prebuilt binaries may be out of date!
prebuild-install info looking for cached prebuild @ {AppData\Roaming}\npm-cache\_prebuilds\a203aa-bindings-v9.0.4-electron-v85-win32-x64.tar.gz
prebuild-install http request GET https://github.com/serialport/node-serialport/releases/download/@serialport/[email protected]/bindings-v9.0.4-electron-v85-win32-x64.tar.gz
prebuild-install http 200 https://github.com/serialport/node-serialport/releases/download/@serialport/[email protected]/bindings-v9.0.4-electron-v85-win32-x64.tar.gz
prebuild-install info downloading to @ {AppData\Roaming}\npm-cache\_prebuilds\a203aa-bindings-v9.0.4-electron-v85-win32-x64.tar.gz.35396-0b268dadf342e.tmp
prebuild-install info renaming to @ {AppData\Roaming}\npm-cache\_prebuilds\a203aa-bindings-v9.0.4-electron-v85-win32-x64.tar.gz
prebuild-install info unpacking @ {AppData\Roaming}\npm-cache\_prebuilds\a203aa-bindings-v9.0.4-electron-v85-win32-x64.tar.gz
prebuild-install info unpack resolved to {Project}\node_modules\@serialport\bindings\build\Release\bindings.node
prebuild-install info install Successfully installed prebuilt binary!
I think the problem (or one of the problems) is you need to bump the version up. Those of us who already downloaded 9.0.4 have a cache of it, and npm is not going to fetch the corrected build binary unless the version is bumped to 9.0.5.
Under semantic versioning, it is very bad practice to re-build something under the same version number.
"Once a versioned package has been released, the contents of that version MUST NOT be modified. Any modifications MUST be released as a new version."
Most helpful comment
@Lovinity Encountered same problem. This problem was not found in [email protected] + electron@8 though.