@crawlee/core 4.0.0-beta.120 → 4.0.0-beta.121

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.
@@ -46,7 +46,7 @@ export declare class ErrorSnapshotter {
46
46
  */
47
47
  contextCaptureSnapshot(context: BrowserCrawlingContext, fileName: string): Promise<SnapshotResult | undefined>;
48
48
  /**
49
- * Save the HTML snapshot of the page, and return the fileName with the extension.
49
+ * Save the HTML snapshot of the page, and return the key it was stored under.
50
50
  */
51
51
  saveHTMLSnapshot(html: string, keyValueStore: Pick<KeyValueStore, 'setValue'>, fileName: string): Promise<string | undefined>;
52
52
  /**
@@ -77,12 +77,14 @@ export class ErrorSnapshotter {
77
77
  }
78
78
  }
79
79
  /**
80
- * Save the HTML snapshot of the page, and return the fileName with the extension.
80
+ * Save the HTML snapshot of the page, and return the key it was stored under.
81
81
  */
82
82
  async saveHTMLSnapshot(html, keyValueStore, fileName) {
83
83
  try {
84
84
  await keyValueStore.setValue(fileName, html, { contentType: 'text/html' });
85
- return `${fileName}.html`;
85
+ // The record key is `fileName` - returning it with an `.html` suffix (as v3 did,
86
+ // where local storage put the extension in the key) would break `getPublicUrl`.
87
+ return fileName;
86
88
  }
87
89
  catch {
88
90
  return undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crawlee/core",
3
- "version": "4.0.0-beta.120",
3
+ "version": "4.0.0-beta.121",
4
4
  "description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
5
5
  "engines": {
6
6
  "node": ">=22.0.0"
@@ -52,9 +52,9 @@
52
52
  "@apify/log": "^2.5.18",
53
53
  "@apify/timeout": "^0.4.4",
54
54
  "@apify/utilities": "^2.15.5",
55
- "@crawlee/fs-storage": "4.0.0-beta.120",
56
- "@crawlee/types": "4.0.0-beta.120",
57
- "@crawlee/utils": "4.0.0-beta.120",
55
+ "@crawlee/fs-storage": "4.0.0-beta.121",
56
+ "@crawlee/types": "4.0.0-beta.121",
57
+ "@crawlee/utils": "4.0.0-beta.121",
58
58
  "@sapphire/async-queue": "^1.5.5",
59
59
  "@sapphire/shapeshift": "^4.0.0",
60
60
  "@vladfrangu/async_event_emitter": "^2.4.6",
@@ -78,5 +78,5 @@
78
78
  }
79
79
  }
80
80
  },
81
- "gitHead": "da5d427c4c1c9dcaea95b151e9c4c7310100885d"
81
+ "gitHead": "5027317de626f5ba6de5047ae9341a898258cc5a"
82
82
  }
package/request.js CHANGED
@@ -167,7 +167,10 @@ class CrawleeRequest {
167
167
  if (label) {
168
168
  userData.label = label;
169
169
  }
170
- this.#userData = { __crawlee: {}, ...userData };
170
+ // Read `__crawlee` explicitly - on a `userData` coming from another Request instance the
171
+ // bag is non-enumerable, so the spread alone would silently drop the internal state
172
+ // (e.g. `skipNavigation`) when a request is re-wrapped after a storage round trip.
173
+ this.#userData = { __crawlee: userData.__crawlee ?? {}, ...userData };
171
174
  // `userData` must stay an enumerable own accessor — serialization in the storages relies on it
172
175
  Object.defineProperties(this, {
173
176
  userData: {
@@ -62,6 +62,17 @@ interface ServiceLocatorInterface {
62
62
  * Get the storage instance manager (shared across all storage types).
63
63
  */
64
64
  getStorageInstanceManager(): StorageInstanceManager;
65
+ /**
66
+ * Returns the currently set services without triggering the implicit creation of defaults.
67
+ * Used to inherit already-materialized services into crawler-scoped service locators.
68
+ * @internal
69
+ */
70
+ getServicesIfSet(): {
71
+ configuration?: Configuration;
72
+ eventManager?: EventManager;
73
+ storageBackend?: StorageBackend;
74
+ logger?: CrawleeLogger;
75
+ };
65
76
  /**
66
77
  * Resets the service locator to its initial state.
67
78
  * Used mainly for testing purposes.
@@ -111,6 +122,13 @@ export declare class ServiceLocator implements ServiceLocatorInterface {
111
122
  * @param logger Optional logger instance to use
112
123
  */
113
124
  constructor(configuration?: Configuration, eventManager?: EventManager, storageBackend?: StorageBackend, logger?: CrawleeLogger);
125
+ /** @internal */
126
+ getServicesIfSet(): {
127
+ configuration?: Configuration;
128
+ eventManager?: EventManager;
129
+ storageBackend?: StorageBackend;
130
+ logger?: CrawleeLogger;
131
+ };
114
132
  getConfiguration(): Configuration;
115
133
  setConfiguration(configuration: Configuration): void;
116
134
  getEventManager(): EventManager;
@@ -63,6 +63,15 @@ export class ServiceLocator {
63
63
  this.#storageBackend = storageBackend;
64
64
  this.#logger = logger;
65
65
  }
66
+ /** @internal */
67
+ getServicesIfSet() {
68
+ return {
69
+ configuration: this.#configuration,
70
+ eventManager: this.#eventManager,
71
+ storageBackend: this.#storageBackend,
72
+ logger: this.#logger,
73
+ };
74
+ }
66
75
  getConfiguration() {
67
76
  if (!this.#configuration) {
68
77
  this.getLogger().debug('No configuration set, implicitly creating and using default Configuration.');