| 118 | await new Promise((resolve, reject) => { |
| 119 | let currentEvent = null; |
| 120 | const handleEvent = async (...parameters) => { |
| 121 | events.add(parameters[0]?.code); |
| 122 | if (currentEvent) { |
| 123 | watcher.close(); |
| 124 | return reject( |
| 125 | new Error( |
| 126 | `Event ${JSON.stringify(parameters)} was emitted while handling ${JSON.stringify( |
| 127 | currentEvent |
| 128 | )}.` |
| 129 | ) |
| 130 | ); |
| 131 | } |
| 132 | currentEvent = parameters; |
| 133 | await wait(100); |
| 134 | currentEvent = null; |
| 135 | }; |
| 136 | // This should work but should not have an effect |
| 137 | watcher.off('event', handleEvent); |
| 138 | watcher.on('event', handleEvent); |