Skip to content

Commit edd8ada

Browse files
author
Guy Bedford
authored
fix: --experimental-top-level-await support (#945)
1 parent bbfb4d1 commit edd8ada

File tree

17 files changed

+442
-11
lines changed

17 files changed

+442
-11
lines changed

.github/workflows/main.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ jobs:
294294
- name: Npm install
295295
run: npm install && cd ./integration-tests/js-compute && npm install
296296

297-
- run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js ${{ matrix.platform == 'viceroy' && '--local' || '' }} ${{ matrix.profile == 'weval' && '--aot' || '' }} ${{ matrix.profile == 'debug' && '--debug-build' || '' }}
297+
- name: Run Tests
298+
run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js ${{ matrix.platform == 'viceroy' && '--local' || '' }} ${{ matrix.profile == 'weval' && '--aot' || '' }} ${{ matrix.profile == 'debug' && '--debug-build' || '' }}
298299
env:
299300
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}
301+
302+
- name: Run TLA Tests
303+
run: SUFFIX_STRING=${{matrix.profile}} node integration-tests/js-compute/test.js --tla ${{ matrix.platform == 'viceroy' && '--local' || '' }} ${{ matrix.profile == 'weval' && '--aot' || '' }} ${{ matrix.profile == 'debug' && '--debug-build' || '' }}
304+
env:
305+
FASTLY_API_TOKEN: ${{ secrets.FASTLY_API_TOKEN }}

integration-tests/cli/help.test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ test('--help should return help on stdout and zero exit code', async function (t
3232
'--engine-wasm <engine-wasm> The JS engine Wasm file path',
3333
'--enable-experimental-high-resolution-time-methods Enable experimental high-resolution fastly.now() method',
3434
'--enable-experimental-top-level-await Enable experimental top level await',
35-
'--debug-build Use the debug build of the JS engine with C++ stack traces',
3635
'ARGS:',
3736
"<input> The input JS script's file path [default: bin/index.js]",
3837
'<output> The file path to write the output Wasm module to [default: bin/main.wasm]',
@@ -59,7 +58,6 @@ test('-h should return help on stdout and zero exit code', async function (t) {
5958
'--engine-wasm <engine-wasm> The JS engine Wasm file path',
6059
'--enable-experimental-high-resolution-time-methods Enable experimental high-resolution fastly.now() method',
6160
'--enable-experimental-top-level-await Enable experimental top level await',
62-
'--debug-build Use the debug build of the JS engine with C++ stack traces',
6361
'ARGS:',
6462
"<input> The input JS script's file path [default: bin/index.js]",
6563
'<output> The file path to write the output Wasm module to [default: bin/main.wasm]',

integration-tests/js-compute/compare-downstream-response.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function compareDownstreamResponse(
2626
} catch {}
2727
errors.push(
2828
new Error(
29-
`[DownstreamResponse: Status mismatch] Expected: ${configResponse.status} - Got: ${actualResponse.statusCode}\n${bodySummary}`,
29+
`[DownstreamResponse: Status mismatch] Expected: ${configResponse.status} - Got: ${actualResponse.statusCode}\n${bodySummary ? `BODY: "${bodySummary}"` : ''}`,
3030
),
3131
);
3232
}

integration-tests/js-compute/fixtures/app/src/response.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { routes } from "./routes.js";
44
import { pass, assert, assertThrows } from "./assertions.js";
55

66
routes.set("/response/stall", async (event) => {
7+
// keep connection open 10 seconds
8+
event.waitUntil(new Promise(resolve => setTimeout(resolve, 10_000)));
79
return new Response(
810
new ReadableStream({
911
start(controller) {

integration-tests/js-compute/fixtures/app/src/timers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -535,12 +535,12 @@ import { CacheOverride } from "fastly:cache-override";
535535
});
536536
routes.set("/setTimeout/fetch-timeout", async () => {
537537
let timedOut = false;
538-
const first = fetch("https://httpbin.org/delay/1", {
538+
const first = fetch("https://httpbin.org/delay/2", {
539539
backend: "httpbin",
540540
cacheOverride: new CacheOverride("pass"),
541541
});
542542
const second = Promise.race([
543-
fetch("https://httpbin.org/delay/1", {
543+
fetch("https://httpbin.org/delay/2", {
544544
backend: "httpbin",
545545
cacheOverride: new CacheOverride("pass"),
546546
}),
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module.exports = {
2+
env: {
3+
es2021: true,
4+
},
5+
extends: "eslint:recommended",
6+
overrides: [],
7+
parserOptions: {
8+
ecmaVersion: "latest",
9+
sourceType: "module",
10+
},
11+
rules: {},
12+
};
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# This file describes a Fastly Compute package. To learn more visit:
2+
# https://developer.fastly.com/reference/fastly-toml/
3+
4+
authors = ["[email protected]"]
5+
description = ""
6+
language = "other"
7+
manifest_version = 2
8+
name = "js-test-app"
9+
service_id = ""
10+
11+
[scripts]
12+
build = "node ../../../../js-compute-runtime-cli.js --enable-experimental-high-resolution-time-methods --enable-experimental-top-level-await src/index.js"
13+
14+
[local_server]
15+
16+
[local_server.backends]
17+
18+
[local_server.backends.TheOrigin]
19+
url = "https://compute-sdk-test-backend.edgecompute.app"
20+
override_host = "compute-sdk-test-backend.edgecompute.app"
21+
22+
[local_server.backends.TheOrigin2]
23+
url = "https://compute-sdk-test-backend.edgecompute.app"
24+
override_host = "compute-sdk-test-backend.edgecompute.app"
25+
26+
[local_server.backends.httpbin]
27+
url = "https://httpbin.org"
28+
override_host = "httpbin.org"
29+
30+
[local_server.backends.httpme]
31+
url = "https://http-me.glitch.me"
32+
override_host = "http-me.glitch.me"
33+
34+
[local_server.config_stores]
35+
[local_server.config_stores.testconfig]
36+
format = "inline-toml"
37+
[local_server.config_stores.testconfig.contents]
38+
"twitter" = "https://twitter.com/fastly"
39+
40+
[local_server.config_stores."aZ1 __ 2"]
41+
format = "inline-toml"
42+
[local_server.config_stores."aZ1 __ 2".contents]
43+
"twitter" = "https://twitter.com/fastly"
44+
45+
[local_server.geolocation]
46+
format = "inline-toml"
47+
48+
[local_server.geolocation.addresses]
49+
[local_server.geolocation.addresses."2.216.196.179"]
50+
as_name = "sky uk limited"
51+
as_number = 5607
52+
area_code = 0
53+
city = "bircotes"
54+
conn_speed = "broadband"
55+
conn_type = "wifi"
56+
continent = "EU"
57+
country_code = "GB"
58+
country_code3 = "GBR"
59+
country_name = "united kingdom"
60+
gmt_offset = 0
61+
latitude = 53.42
62+
longitude = -1.05
63+
metro_code = 826039
64+
postal_code = "dn11 8af"
65+
proxy_description = "?"
66+
proxy_type = "?"
67+
region = "NTT"
68+
utc_offset = 0
69+
[local_server.geolocation.addresses."2607:f0d0:1002:51::4"]
70+
as_name = "softlayer technologies inc."
71+
as_number = 36351
72+
area_code = 214
73+
city = "dallas"
74+
conn_speed = "broadband"
75+
conn_type = "wired"
76+
continent = "NA"
77+
country_code = "US"
78+
country_code3 = "USA"
79+
country_name = "united states"
80+
gmt_offset = -600
81+
latitude = 32.94
82+
longitude = -96.84
83+
metro_code = 623
84+
postal_code = "75244"
85+
proxy_description = "?"
86+
proxy_type = "hosting"
87+
region = "TX"
88+
utc_offset = -600
89+
90+
[local_server.kv_stores]
91+
92+
[[local_server.kv_stores.example-test-kv-store]]
93+
key = "placeholder"
94+
data = 'placholder'
95+
96+
[[local_server.kv_stores.example-test-kv-store-sm]]
97+
key = "placeholder"
98+
data = 'placholder'
99+
100+
[local_server.secret_stores]
101+
[[local_server.secret_stores.example-test-secret-store]]
102+
key = "first"
103+
data = "This is also some secret data"
104+
[[local_server.secret_stores.example-test-secret-store]]
105+
key = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
106+
data = "This is some secret data"
107+
108+
[local_server.device_detection]
109+
format = "inline-toml"
110+
111+
[local_server.device_detection.user_agents]
112+
[local_server.device_detection.user_agents."Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20100101 Firefox/10.0 FBAN/FBIOS;FBAV/8.0.0.28.18;FBBV/1665515;FBDV/iPhone4,1;FBMD/iPhone;FBSN/iPhone OS;FBSV/7.0.4;FBSS/2; FBCR/Telekom.de;FBID/phone;FBLC/de_DE;FBOP/5"]
113+
user_agent = {}
114+
os = {}
115+
device = {name = "iPhone", brand = "Apple", model = "iPhone4,1", hwtype = "Mobile Phone", is_ereader = false, is_gameconsole = false, is_mediaplayer = false, is_mobile = true, is_smarttv = false, is_tablet = false, is_tvplayer = false, is_desktop = false, is_touchscreen = true }
116+
117+
[local_server.device_detection.user_agents."ghosts-app/1.0.2.1 (ASUSTeK COMPUTER INC.; X550CC; Windows 8 (X86); en)"]
118+
user_agent = {}
119+
os = {}
120+
device = {name = "Asus TeK", brand = "Asus", model = "TeK", is_desktop = false }
121+
122+
123+
[setup]
124+
[setup.backends]
125+
126+
[setup.backends.httpbin]
127+
address = "httpbin.org"
128+
port = 443
129+
130+
[setup.backends.httpme]
131+
address = "http-me.glitch.me"
132+
port = 443
133+
134+
[setup.backends.TheOrigin]
135+
address = "compute-sdk-test-backend.edgecompute.app"
136+
port = 443
137+
[setup.backends.TheOrigin2]
138+
address = "compute-sdk-test-backend.edgecompute.app"
139+
port = 443

0 commit comments

Comments
 (0)