Skip to content

Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.

Renaming call params

Marek Trunkata20241213989
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3d29b2c24..2ea0b59a6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,8 +3,9 @@ xxx
- Fixed `RequestQueue.addRequest()` to gracefully handle invalid URLs
- Renamed `RequestOperationInfo` to `QueueOperationInfo`
- Added `request` field to `QueueOperationInfo`
-- **WARNING**: Deprecated parameter `timeoutSecs` of `Apify.call()` was removed use `waitSecs` instead.
- Parameter `timeout` is used for actor run timeout.
+- **WARNING**: Parameter `timeoutSecs` of `Apify.call()` is used for actor run timeout.
+ For time of waiting for run to finish use `waitSecs` parameter.
+- **WARNING**: Parameter `memory` of `Apify.call()` was renamed to `memoryMbytes`.
- Added `Apify.callTask()` that enables to start actor task and fetch its output.
0.8.18 / 2018-10-30
diff --git a/src/actor.js b/src/actor.js
index f83a1369a..ae72df0ab 100644
--- a/src/actor.js
+++ b/src/actor.js
@@ -273,10 +273,10 @@ export const main = (userFunc) => {
* `String` or `Buffer`.
* @param {String} [options.token]
* User API token that is used to run the actor. By default, it is taken from the `APIFY_TOKEN` environment variable.
- * @param {Number} [options.memory]
+ * @param {Number} [options.memoryMbytes]
* Memory in megabytes which will be allocated for the new actor run.
* If not provided, the run uses memory of the default actor run configuration.
- * @param {Number} [options.timeout]
+ * @param {Number} [options.timeoutSecs]
* Timeout for the act run in seconds. Zero value means there is no timeout.
* If not provided, the run uses timeout of the default actor run configuration.
* @param {String} [options.build]
@@ -312,14 +312,14 @@ export const call = async (actId, input, options = {}) => {
checkParamOrThrow(token, 'token', 'Maybe String');
// RunAct() options.
- const { build, memory, timeout } = optionsCopy;
+ const { build, memoryMbytes, timeoutSecs } = optionsCopy;
const runActOpts = {};
checkParamOrThrow(build, 'build', 'Maybe String');
- checkParamOrThrow(memory, 'memory', 'Maybe Number');
- checkParamOrThrow(timeout, 'timeout', 'Maybe Number');
+ checkParamOrThrow(memoryMbytes, 'memoryMbytes', 'Maybe Number');
+ checkParamOrThrow(timeoutSecs, 'timeoutSecs', 'Maybe Number');
if (build) runActOpts.build = build;
- if (memory) runActOpts.memory = memory;
- if (timeout >= 0) runActOpts.timeout = timeout; // Zero is valid value!
+ if (memoryMbytes) runActOpts.memory = memoryMbytes;
+ if (timeoutSecs >= 0) runActOpts.timeout = timeoutSecs; // Zero is valid value!
if (input) {
input = maybeStringify(input, optionsCopy);
diff --git a/test/actor.js b/test/actor.js
index 5f2c43055..7321d4df0 100644
--- a/test/actor.js
+++ b/test/actor.js
@@ -243,12 +243,20 @@ describe('Apify.call()', () => {
const output = { contentType, body: 'some-output' };
const expected = Object.assign({}, finishedRun, { output });
const build = 'xxx';
- const memory = 1024;
- const timeout = 60;
+ const memoryMbytes = 1024;
+ const timeoutSecs = 60;
const actsMock = sinon.mock(Apify.client.acts);
actsMock.expects('runAct')
- .withExactArgs({ token, actId, contentType: `${contentType}; charset=utf-8`, body: input, build, memory, timeout })
+ .withExactArgs({
+ token,
+ actId,
+ contentType: `${contentType}; charset=utf-8`,
+ body: input,
+ build,
+ memory: memoryMbytes,
+ timeout: timeoutSecs,
+ })
.once()
.returns(Promise.resolve(runningRun));
actsMock.expects('getRun')
@@ -267,7 +275,7 @@ describe('Apify.call()', () => {
.returns(Promise.resolve(output));
return Apify
- .call(actId, input, { contentType, token, disableBodyParser: true, build, memory, timeout })
+ .call(actId, input, { contentType, token, disableBodyParser: true, build, memoryMbytes, timeoutSecs })
.then((callOutput) => {
expect(callOutput).to.be.eql(expected);
keyValueStoresMock.restore();
@@ -549,7 +557,7 @@ describe('Apify.call()', () => {
});
});
- it('returns immediately with zero timeout', () => {
+ it('returns immediately with zero ', () => {
const actId = 'some-act-id';
const token = 'some-token';
const defaultKeyValueStoreId = 'some-store-id';
@@ -686,7 +694,7 @@ describe('Apify.callTask()', () => {
});
});
- it('timeouts as expected with unfinished run', () => {
+ it('s as expected with unfinished run', () => {
const waitSecs = 1;
const taskId = 'some-act-id';
const actId = 'xxx';
@@ -766,7 +774,7 @@ describe('Apify.callTask()', () => {
});
});
- it('returns immediately with zero timeout', () => {
+ it('returns immediately with zero ', () => {
const waitSecs = 0;
const taskId = 'some-act-id';
const actId = 'xxx';