opentok-node
opentok-node copied to clipboard
listStreams: TypeError: Cannot read properties of undefined (reading 'map')
The optional chaining is not done properly in the callback and causes a crash.
TypeError: Cannot read properties of undefined (reading 'map')
at callback (/node_modules/opentok/lib/client.js:413:21)
at /node_modules/opentok/lib/client.js:107:7
FIX: ?.map((steam)) -> ?.map?.((stream))
Client.prototype.listStreams = function listStreams(sessionId, cb) {
const url = this.c.apiUrl
+ this.c.endpoints.listStreams
.replace(/<%apiKey%>/g, this.c.apiKey)
.replace(/<%sessionId%>/g, sessionId);
api({
url: url,
method: 'GET',
headers: this.generateHeaders(),
callback: (err, body) => {
cb(err, body?.items?.map((stream) => new Stream(JSON.stringify(stream))) || [])
},
});
};
Would be nice if you could test changes even once before publishing a new version.
@tapz apologizes for this issue. There was an update made to the API that caused this issue to happen in the back end. The SDK now has guards for this and the API team will work on preventing this issue from happening going forward