Skip to content

Commit

Permalink
fix: Fix apify create on Node 19+, add Node 20 to CI test roster (#359
Browse files Browse the repository at this point in the history
)

When you ran `apify create` on Node 19 or higher, the CLI got stuck
running after the command finished, because Node 19+ uses HTTP keepalive
by default, and the HTTP connections that were open when downloading the
template zip were stuck hanging (because we never closed them after
performing the redirects). This fixes it by forcefully closing the
responses with the redirects.

Also, this adds Node 20 to the CI test roster, now that it's out and
stable.
  • Loading branch information
fnesveda authored Apr 27, 2023
1 parent 983c0ed commit 1f884af
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [ 16, 18 ]
node-version: [ 16, 18, 20 ]

steps:
-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [ 16, 18 ]
node-version: [ 16, 18, 20 ]

steps:
-
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ USAGE
$ apify actor
```

_See code: [src/commands/actor/index.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/actor/index.js)_
_See code: [src/commands/actor/index.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/actor/index.js)_

## `apify actor:get-input`

Expand All @@ -309,7 +309,7 @@ USAGE
$ apify actor:get-input
```

_See code: [src/commands/actor/get-input.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/actor/get-input.js)_
_See code: [src/commands/actor/get-input.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/actor/get-input.js)_

## `apify actor:get-value KEY`

Expand All @@ -323,7 +323,7 @@ ARGUMENTS
KEY Key of the record in key-value store
```

_See code: [src/commands/actor/get-value.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/actor/get-value.js)_
_See code: [src/commands/actor/get-value.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/actor/get-value.js)_

## `apify actor:push-data [ITEM]`

Expand All @@ -344,7 +344,7 @@ DESCRIPTION
$ cat ./test.json | apify actor:push-data
```

_See code: [src/commands/actor/push-data.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/actor/push-data.js)_
_See code: [src/commands/actor/push-data.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/actor/push-data.js)_

## `apify actor:set-value KEY [VALUE]`

Expand Down Expand Up @@ -374,7 +374,7 @@ DESCRIPTION
$ cat ./my-text-file.txt | apify actor:set-value KEY --contentType text/plain
```

_See code: [src/commands/actor/set-value.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/actor/set-value.js)_
_See code: [src/commands/actor/set-value.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/actor/set-value.js)_

## `apify call [ACTID]`

Expand All @@ -399,7 +399,7 @@ DESCRIPTION
takes input for the actor from the default local key-value store by default.
```

_See code: [src/commands/call.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/call.js)_
_See code: [src/commands/call.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/call.js)_

## `apify create [ACTORNAME]`

Expand All @@ -421,7 +421,7 @@ OPTIONS
--skip-dependency-install Skip installing actor dependencies.
```

_See code: [src/commands/create.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/create.js)_
_See code: [src/commands/create.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/create.js)_

## `apify info`

Expand All @@ -435,7 +435,7 @@ DESCRIPTION
The information is printed to the console.
```

_See code: [src/commands/info.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/info.js)_
_See code: [src/commands/info.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/info.js)_

## `apify init [ACTORNAME]`

Expand All @@ -455,7 +455,7 @@ DESCRIPTION
WARNING: The directory at "storage" will be overwritten if it already exists.
```

_See code: [src/commands/init.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/init.js)_
_See code: [src/commands/init.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/init.js)_

## `apify login`

Expand All @@ -473,7 +473,7 @@ DESCRIPTION
"apify" commands. To log out, call "apify logout".
```

_See code: [src/commands/login.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/login.js)_
_See code: [src/commands/login.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/login.js)_

## `apify logout`

Expand All @@ -488,7 +488,7 @@ DESCRIPTION
call "apify login".
```

_See code: [src/commands/logout.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/logout.js)_
_See code: [src/commands/logout.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/logout.js)_

## `apify push [ACTORID]`

Expand Down Expand Up @@ -523,7 +523,7 @@ DESCRIPTION
WARNING: If the target actor already exists in your Apify account, it will be overwritten!
```

_See code: [src/commands/push.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/push.js)_
_See code: [src/commands/push.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/push.js)_

## `apify run`

Expand Down Expand Up @@ -553,7 +553,7 @@ DESCRIPTION
package.json file. You can set up your own main file or environment variables by changing it.
```

_See code: [src/commands/run.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/run.js)_
_See code: [src/commands/run.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/run.js)_

## `apify secrets`

Expand Down Expand Up @@ -581,7 +581,7 @@ DESCRIPTION
of the actor.
```

_See code: [src/commands/secrets/index.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/secrets/index.js)_
_See code: [src/commands/secrets/index.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/secrets/index.js)_

## `apify secrets:add NAME VALUE`

Expand All @@ -599,7 +599,7 @@ DESCRIPTION
The secrets are stored to a file at ~/.apify
```

_See code: [src/commands/secrets/add.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/secrets/add.js)_
_See code: [src/commands/secrets/add.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/secrets/add.js)_

## `apify secrets:rm NAME`

Expand All @@ -613,7 +613,7 @@ ARGUMENTS
NAME Name of the secret
```

_See code: [src/commands/secrets/rm.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/secrets/rm.js)_
_See code: [src/commands/secrets/rm.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/secrets/rm.js)_

## `apify vis [PATH]`

Expand All @@ -637,5 +637,5 @@ DESCRIPTION
You can also pass any custom path to your input schema to have it validated instead.
```

_See code: [src/commands/vis.js](https://github.com/apify/apify-cli/blob/v0.16.0/src/commands/vis.js)_
_See code: [src/commands/vis.js](https://github.com/apify/apify-cli/blob/v0.16.1/src/commands/vis.js)_
<!-- commandsstop -->
4 changes: 2 additions & 2 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion oclif.manifest.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "apify-cli",
"version": "0.16.0",
"version": "0.16.1",
"description": "Apify command-line interface helps you create, develop, build and run Apify actors, and manage the Apify cloud platform.",
"main": "index.js",
"scripts": {
Expand Down
3 changes: 3 additions & 0 deletions src/lib/create-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ const PROGRAMMING_LANGUAGES = ['JavaScript', 'TypeScript', 'Python'];
exports.httpsGet = async (url) => {
return new Promise((resolve, reject) => {
https.get(url, (response) => {
// Handle redirects
if (response.statusCode === 301 || response.statusCode === 302) {
resolve(exports.httpsGet(response.headers.location));
// Destroy the response to close the HTTP connection, otherwise this hangs for a long time with Node 19+ (due to HTTP keep-alive).
response.destroy();
} else {
resolve(response);
}
Expand Down
2 changes: 1 addition & 1 deletion test/commands/vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('apify vis', () => {
await command.run(['vis', path.join(__dirname, 'input-schemas', 'unparsable.json')]);
throw new Error('This should have failed!');
} catch (err) {
expect(err.message).to.contain('Unexpected token "}');
expect(err.message).to.contain.oneOf(['Unexpected token "}', 'Expected \',\' or \']\' after array element']);
}
});
});

0 comments on commit 1f884af

Please sign in to comment.