-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: collection[(i + 2)] is not a function #26
Comments
Hi! Could you please provide more code and node version? Or just this code causes this error |
I don't really have an isolated report, the stacktrace doesn't really tell me much. I tried to remove most of the irrelevant code, each file1const Connection = function (initBuffer, config, emitter) {
this.socket = new TLSSocket
this.socket
.setNoDelay()
.connect(1234, `foo.bar`)
.on(`data`, foo => {
let parsedCommand = new CommandParser(foo)
emitter.emit(parsedCommand.command, parsedCommand, this) // Error on this line
while (parsedCommand.subarray !== undefined) {
parsedCommand = new CommandParser(parsedCommand.subarray)
emitter.emit(parsedCommand.command, parsedCommand, this)
}
})
.write(initBuffer)
}
export const
ReadOnlyConnection = function (initBuffer, config, emitter) {
Connection.call(this, initBuffer, config, emitter)
},
WriteOnlyConnection = function (initBuffer, config, emitter) {
Connection.call(this, initBuffer, config, emitter)
},
ReadWriteConnection = function (initBuffer, config, emitter) {
Connection.call(this, initBuffer, config, emitter)
} file2import { EventEmitter } from 'tseep'
import { ReadOnlyConnection, WriteOnlyConnection, ReadWriteConnection } from './file1.js'
export const Client = (config = new Config) => {
for (const i of read.keys())
read[i] = new ReadOnlyConnection(initBuffer, config, emitter)
for (const i of write.keys())
write[i] = new WriteOnlyConnection(initBuffer, config, emitter)
} |
very strange. may be you could send whole project to my email "[email protected]" so i could debug it looking at tseep's code it could happen only if you somehow modify private fields or it somehow adds new listener WHILE it was baking collection. but probably its something else after listener was added, listeners should be more than 1500, and numbers of items should be mod div by %10 or %4 or %3. also will be cool if you manually add try catch on eval inside bakeCollection, here try {
var funcFactory = eval(funcFactoryCode);
return funcFactory(collection);
} catch (err) {
console.error(err);
console.log(collection);
throw err;
} so we could look inside. It also maybe happens because listener adds another listener of same eventName and emits same eventName, so it will be recursion. |
or may be recursion which clears all listeners |
Occurring on an emit:
Seemingly at random.
The text was updated successfully, but these errors were encountered: