#<DOMException> when setting onmidimessage
DominikKrajcer opened this issue · 6 comments
Hello,
In a node.js environment when I set onmidimessage I get:
(node:59882) UnhandledPromiseRejectionWarning: #< DOMException >
var navigator = require('jzz');
const onSuccess = (midiAccess) => {
for (const input of midiAccess.inputs.values()) {
input.onmidimessage = console.log;
}
};
const onFail = console.log;
navigator.requestMIDIAccess().then(onSuccess, onFail);
Tested on win and mac.
node: v12.18.0
Please try this change:
//input.onmidimessage = console.log;
input.onmidimessage = function(msg) { console.log(msg); }
//const onFail = console.log;
const onFail = function(err) { console.log(err); }
Unfortunately it doesn't work. I've also tried web-midi-api lib and below 2.0.6 I could set onmidimessage but my keyboard couldn't trigger it and above this ver I got DOMException error. I have such a problem just in node.js
@jazz-soft
I've tried to open a port before assigning onmidimessage but I got this error (win and mac) reject(new DOMException('InvalidAccessError', 'Port is not available', 15))
DOMException {
name: 'InvalidAccessError',
message: 'Port is not available',
code: 15
}
@jazz-soft Have you reproduced it?
This seems to be a valid Web MIDI exception when the port is used by another application and cannot be open.
Let me double check the specs...
Ok, for some reason your port cannot be open. (Most likely, used by another app.)
According to specs, open() should throw, but onmidimessage should not.
Thanks a lot for catching this!
Please try the latest version.