You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(core)!: drop EventEmitter dependency from SessionPool
SessionPool no longer extends EventEmitter and no longer fires a
sessionRetired event. The Session->SessionPool back-reference, the
sessionPool constructor option on Session, and the EVENT_SESSION_RETIRED
constant are gone with it. The only consumer of that event was the
browser crawler, which now retires browsers via the per-request context
pipeline cleanup. Custom createSessionFunction implementations that
manually constructed Session instances should drop the sessionPool
argument.
Copy file name to clipboardExpand all lines: docs/upgrading/upgrading_v4.md
+23-2Lines changed: 23 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -127,16 +127,37 @@ new SessionPool({
127
127
```typescript
128
128
newSessionPool({
129
129
sessionOptions: { maxUsageCount: 5 },
130
-
createSessionFunction: async (pool, opts) =>
130
+
createSessionFunction: async (_pool, opts) =>
131
131
newSession({
132
132
...opts?.sessionOptions, // already merged with pool-wide defaults
133
-
sessionPool: pool,
134
133
}),
135
134
});
136
135
```
137
136
138
137
If you were already spreading `pool.sessionOptions`, the change is harmless - pool defaults now appear twice in the spread chain, with the later (per-call) one winning, exactly as before.
139
138
139
+
## `Session` no longer requires a `sessionPool` reference
140
+
141
+
`Session` no longer holds a back-reference to its `SessionPool` and no longer emits a `sessionRetired` event when retired. The `sessionPool` constructor option is gone, `SessionPool` is no longer an `EventEmitter`, and the `EVENT_SESSION_RETIRED` constant is no longer exported. Custom `createSessionFunction` implementations that constructed `Session` instances manually should drop the `sessionPool` argument.
142
+
143
+
**Before:**
144
+
```typescript
145
+
newSessionPool({
146
+
createSessionFunction: async (pool, opts) =>
147
+
newSession({ ...opts?.sessionOptions, sessionPool: pool }),
148
+
});
149
+
```
150
+
151
+
**After:**
152
+
```typescript
153
+
newSessionPool({
154
+
createSessionFunction: async (_pool, opts) =>
155
+
newSession({ ...opts?.sessionOptions }),
156
+
});
157
+
```
158
+
159
+
If you previously subscribed to `sessionRetired` on the pool to clean up resources tied to a session, perform the cleanup at the end of your request handler (or via a context-pipeline cleanup hook) by checking `session.isUsable()` instead. `Session.retire()` is now a terminal state — once retired, `isUsable()` returns `false` permanently and cannot be undone by a subsequent `markGood()`.
160
+
140
161
## `retireOnBlockedStatusCodes` is removed from `Session`
141
162
142
163
`Session.retireOnBlockedStatusCodes` is removed. Blocked status code handling is now internal to the crawler. Configure blocked status codes via the `blockedStatusCodes` crawler option (moved from `sessionPoolOptions`).
0 commit comments