| 153 | } |
| 154 | |
| 155 | _getActivity(uid, hook) { |
| 156 | const h = this._activities.get(uid); |
| 157 | if (!h) { |
| 158 | // If we allowed handles without init we ignore any further life time |
| 159 | // events this makes sense for a few tests in which we enable some hooks |
| 160 | // later |
| 161 | if (this._allowNoInit) { |
| 162 | const stub = { uid, type: 'Unknown', handleIsObject: true, handle: {} }; |
| 163 | this._activities.set(uid, stub); |
| 164 | return stub; |
| 165 | } else if (!isMainThread) { |
| 166 | // Worker threads start main script execution inside of an AsyncWrap |
| 167 | // callback, so we don't yield errors for these. |
| 168 | return null; |
| 169 | } |
| 170 | const err = new Error(`Found a handle whose ${hook}` + |
| 171 | ' hook was invoked but not its init hook'); |
| 172 | throw err; |
| 173 | } |
| 174 | return h; |
| 175 | } |
| 176 | |
| 177 | _init(uid, type, triggerAsyncId, handle) { |
| 178 | const activity = { |