Skip to content

Commit

Permalink
download stdlib to file before sourcing
Browse files Browse the repository at this point in the history
the curl_retry_on_18 function re-starts the entire download, as -C - (continue) is not supported by all servers

if a download restarts this way, some file contents would be duplicate from the previous attempt, all sourced from stdout, breaking the code sourcing
  • Loading branch information
dzuelke committed Jul 25, 2018
1 parent e3867d9 commit 3cee06a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
- Trap unhandled build errors with dedicated message [David Zuelke]
- Summarize all emitted warnings if subsequent build error occurs [David Zuelke]

### FIX

- stdlib download during build init may theoretically fail on download restart [David Zuelke]

## v139 (2018-07-20)

### ADD
Expand Down
13 changes: 12 additions & 1 deletion bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,18 @@ source $bp_dir/bin/util/common.sh
trap 'err_trap' ERR

# stdlib
source /dev/stdin <<< "$(curl_retry_on_18 --silent https://lang-common.s3.amazonaws.com/buildpack-stdlib/v8/stdlib.sh)"
# download to a file first, as the function restarts the entire download on code 18 connection reset (not all servers support -C)
curl_retry_on_18 --fail --silent --location -o $bp_dir/bin/util/stdlib.sh https://lang-common.s3.amazonaws.com/buildpack-stdlib/v8/stdlib.sh || {
error <<-EOF
Failed to download standard library for bootstrapping!
This is most likely a temporary internal error. If the problem
persists, make sure that you are not running a custom or forked
version of the Heroku PHP buildpack which may need updating.
EOF
}
source $bp_dir/bin/util/stdlib.sh
rm $bp_dir/bin/util/stdlib.sh

# failure counting
source $bp_dir/bin/util/failures.sh
Expand Down

0 comments on commit 3cee06a

Please sign in to comment.