@opencraw/driver 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -47,7 +47,7 @@ npx opencraw-driver # then write JSON-RPC lines to it
47
47
  | `work.done`, `work.failed` | driver | How an item ended: its report and records, or its outcome (`failure`, `neutral`). |
48
48
  | `callout` | driver | A hook, captcha solver or access plugin the client serves (`request.kind`: `hook`, `captcha`, `access`). The request and its answer are core's [callout contract](../core/README.md): `ok`, `error`, or `pending` with `retryAfterMs`, asked again with the same idempotency key. |
49
49
 
50
- Every answer comes back before the driver stops, even when a client writes its last requests and closes
50
+ A run's answer (`run`, `work`) always comes before any of its events, records or callouts. Every answer comes back before the driver stops, even when a client writes its last requests and closes
51
51
  stdin at once. Answers may arrive out of order; match them by `id`.
52
52
 
53
53
  ## For client authors
package/dist/index.esm.js CHANGED
@@ -369,6 +369,7 @@ function runSessions(notify, ask) {
369
369
  const track = (runId, crawler, crawling) => {
370
370
  running.set(runId, crawler);
371
371
  void (async () => {
372
+ await new Promise((resolve) => setImmediate(resolve));
372
373
  try {
373
374
  notify("finished", { runId, report: await crawling() });
374
375
  } catch (error) {
package/dist/main.esm.js CHANGED
@@ -330,6 +330,7 @@ function runSessions(notify, ask) {
330
330
  const track = (runId, crawler, crawling) => {
331
331
  running.set(runId, crawler);
332
332
  void (async () => {
333
+ await new Promise((resolve) => setImmediate(resolve));
333
334
  try {
334
335
  notify("finished", { runId, report: await crawling() });
335
336
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencraw/driver",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "OpenCraw's driver: the engine over JSON-RPC on stdio, for clients in other languages",
5
5
  "license": "MIT",
6
6
  "type": "module",