Skip to content

Commit 12e5f9f

Browse files
authored
fix: respect forceCloud in KeyValueStore.getPublicUrl() calls (#462)
The original check from #302 was not sufficient. When the user passes `forceCloud: true` to `KVS.open()`, the SDK instance points to a platform-backed KVS, even if the script is run locally. This PR proposes checking the runtime type of `KeyValueStore.client`. If this is a client instance from `apify-client`, we're communicating with the platform, regardless of the place of execution (Platform / locally). Closes #459
1 parent 6e48b85 commit 12e5f9f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/apify/src/key_value_store.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { StorageManagerOptions } from '@crawlee/core';
22
import { KeyValueStore as CoreKeyValueStore } from '@crawlee/core';
3+
import { KeyValueStoreClient as RemoteKeyValueStoreClient } from 'apify-client';
34

45
import { createHmacSignature } from '@apify/utilities';
56

@@ -18,7 +19,13 @@ export class KeyValueStore extends CoreKeyValueStore {
1819
*/
1920
override getPublicUrl(key: string): string {
2021
const config = this.config as Configuration;
21-
if (!config.get('isAtHome') && getPublicUrl) {
22+
23+
const isLocalStore = !(
24+
// eslint-disable-next-line dot-notation
25+
(this['client'] instanceof RemoteKeyValueStoreClient)
26+
);
27+
28+
if (isLocalStore && getPublicUrl) {
2229
return getPublicUrl.call(this, key);
2330
}
2431

0 commit comments

Comments
 (0)