Skip to content

Commit 4252161

Browse files
committed
Merge branch 'main' into test
# Conflicts: # Cargo.lock # Cargo.toml # DEVELOPERS.md # cli/Cargo.toml # crates/base/src/deno_runtime.rs # crates/base/src/worker/pool.rs # crates/base/tests/integration_tests.rs # crates/fs/impl/deno_compile_fs.rs # crates/fs/impl/static_fs.rs # crates/fs/impl/virtual_fs.rs # crates/fs/lib.rs # crates/fs/rt.rs # crates/graph/graph_util.rs # crates/graph/lib.rs # crates/module_loader/standalone/mod.rs # examples/main/index.ts # examples/serve-html/index.ts # ext/ai/Cargo.toml # ext/ai/onnxruntime/tensor.rs # ext/ai/utilities/Cargo.toml # ext/ai/utilities/lib.rs # ext/core/js/bootstrap.js # ext/core/js/namespaces.js # ext/event_worker/Cargo.toml # ext/event_worker/js_interceptors.rs # ext/node/Cargo.toml # ext/node/lib.rs # ext/node/ops/crypto/cipher.rs # ext/node/ops/crypto/dh.rs # ext/node/ops/crypto/keys.rs # ext/node/ops/crypto/mod.rs # ext/node/ops/crypto/pkcs3.rs # ext/node/ops/crypto/sign.rs # ext/node/ops/crypto/x509.rs # ext/node/polyfills/internal/crypto/cipher.ts # ext/node/polyfills/internal/crypto/keygen.ts # ext/workers/lib.rs
2 parents 42c9b21 + ec67c39 commit 4252161

File tree

19 files changed

+1047
-1043
lines changed

19 files changed

+1047
-1043
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
run: ./scripts/install_onnx.sh ${{ env.ONNXRUNTIME_VERSION }} linux x64 /tmp/onnxruntime
7575

7676
- name: Install S3 credentials for testing
77-
if: |
77+
if: |
7878
github.actor != 'dependabot[bot]' &&
7979
(
8080
github.event_name != 'pull_request'
Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,71 @@
1-
import * as path from 'jsr:@std/path';
1+
import * as path from "jsr:@std/path";
22

33
const handle = setInterval(async () => {
4-
try {
5-
const cleanupCount = await EdgeRuntime.ai.tryCleanupUnusedSession();
6-
if (cleanupCount == 0) {
7-
return;
8-
}
9-
console.log('EdgeRuntime.ai.tryCleanupUnusedSession', cleanupCount);
10-
} catch (e) {
11-
console.error(e.toString());
12-
}
4+
try {
5+
const cleanupCount = await EdgeRuntime.ai.tryCleanupUnusedSession();
6+
if (cleanupCount == 0) {
7+
return;
8+
}
9+
console.log("EdgeRuntime.ai.tryCleanupUnusedSession", cleanupCount);
10+
} catch (e) {
11+
console.error(e.toString());
12+
}
1313
}, 100);
1414

15-
addEventListener('beforeunload', () => {
16-
clearInterval(handle);
15+
addEventListener("beforeunload", () => {
16+
clearInterval(handle);
1717
});
1818

1919
Deno.serve(async (req: Request) => {
20-
console.log(req.url);
21-
const url = new URL(req.url);
22-
const { pathname } = url;
23-
const service_name = pathname;
20+
console.log(req.url);
21+
const url = new URL(req.url);
22+
const { pathname } = url;
23+
const service_name = pathname;
2424

25-
if (!service_name || service_name === '') {
26-
const error = { msg: 'missing function name in request' };
27-
return new Response(
28-
JSON.stringify(error),
29-
{ status: 400, headers: { 'Content-Type': 'application/json' } },
30-
);
31-
}
25+
if (!service_name || service_name === "") {
26+
const error = { msg: "missing function name in request" };
27+
return new Response(
28+
JSON.stringify(error),
29+
{ status: 400, headers: { "Content-Type": "application/json" } },
30+
);
31+
}
3232

33-
const servicePath = path.join('test_cases/ai-ort-rust-backend', pathname);
33+
const servicePath = path.join("test_cases/ai-ort-rust-backend", pathname);
3434

35-
const createWorker = async () => {
36-
const memoryLimitMb = 1500;
37-
const workerTimeoutMs = 10 * 60 * 1000;
38-
const cpuTimeSoftLimitMs = 10 * 60 * 1000;
39-
const cpuTimeHardLimitMs = 10 * 60 * 1000;
40-
const noModuleCache = false;
41-
const envVarsObj = Deno.env.toObject();
42-
const envVars = Object.keys(envVarsObj).map((k) => [k, envVarsObj[k]]);
35+
const createWorker = async () => {
36+
const memoryLimitMb = 1500;
37+
const workerTimeoutMs = 10 * 60 * 1000;
38+
const cpuTimeSoftLimitMs = 10 * 60 * 1000;
39+
const cpuTimeHardLimitMs = 10 * 60 * 1000;
40+
const noModuleCache = false;
41+
const envVarsObj = Deno.env.toObject();
42+
const envVars = Object.keys(envVarsObj).map((k) => [k, envVarsObj[k]]);
4343

44-
return await EdgeRuntime.userWorkers.create({
45-
servicePath,
46-
memoryLimitMb,
47-
workerTimeoutMs,
48-
cpuTimeSoftLimitMs,
49-
cpuTimeHardLimitMs,
50-
noModuleCache,
51-
envVars,
52-
});
53-
};
44+
return await EdgeRuntime.userWorkers.create({
45+
servicePath,
46+
memoryLimitMb,
47+
workerTimeoutMs,
48+
cpuTimeSoftLimitMs,
49+
cpuTimeHardLimitMs,
50+
noModuleCache,
51+
envVars,
52+
});
53+
};
5454

55-
const callWorker = async () => {
56-
try {
57-
const worker = await createWorker();
58-
return await worker.fetch(req);
59-
} catch (e) {
60-
console.error(e);
55+
const callWorker = async () => {
56+
try {
57+
const worker = await createWorker();
58+
return await worker.fetch(req);
59+
} catch (e) {
60+
console.error(e);
6161

62-
const error = { msg: e.toString() };
63-
return new Response(
64-
JSON.stringify(error),
65-
{ status: 500, headers: { 'Content-Type': 'application/json' } },
66-
);
67-
}
68-
};
62+
const error = { msg: e.toString() };
63+
return new Response(
64+
JSON.stringify(error),
65+
{ status: 500, headers: { "Content-Type": "application/json" } },
66+
);
67+
}
68+
};
6969

70-
return await callWorker();
70+
return await callWorker();
7171
});
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import file from './version.json' with { type: 'json' };
1+
import file from "./version.json" with { type: "json" };
22

33
Deno.serve(async () => {
4-
return new Response(
5-
JSON.stringify({ version: file.version }),
6-
{ status: 200, headers: { 'Content-Type': 'application/json' } },
7-
);
4+
return new Response(
5+
JSON.stringify({ version: file.version }),
6+
{ status: 200, headers: { "Content-Type": "application/json" } },
7+
);
88
});
Lines changed: 79 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,95 @@
1-
console.log('main function started');
1+
console.log("main function started");
22

33
function parseIntFromHeadersOrDefault(req: Request, key: string, val: number) {
4-
const headerValue = req.headers.get(key);
5-
if (!headerValue) {
6-
return val;
7-
}
4+
const headerValue = req.headers.get(key);
5+
if (!headerValue) {
6+
return val;
7+
}
88

9-
const parsedValue = parseInt(headerValue);
10-
if (isNaN(parsedValue)) {
11-
return val;
12-
}
9+
const parsedValue = parseInt(headerValue);
10+
if (isNaN(parsedValue)) {
11+
return val;
12+
}
1313

14-
return parsedValue;
14+
return parsedValue;
1515
}
1616

1717
Deno.serve((req: Request) => {
18-
console.log(req.url);
19-
const url = new URL(req.url);
20-
const { pathname } = url;
21-
const path_parts = pathname.split('/');
22-
const service_name = path_parts[1];
18+
console.log(req.url);
19+
const url = new URL(req.url);
20+
const { pathname } = url;
21+
const path_parts = pathname.split("/");
22+
const service_name = path_parts[1];
2323

24-
if (!service_name || service_name === '') {
25-
const error = { msg: 'missing function name in request' };
26-
return new Response(
27-
JSON.stringify(error),
28-
{ status: 400, headers: { 'Content-Type': 'application/json' } },
29-
);
30-
}
24+
if (!service_name || service_name === "") {
25+
const error = { msg: "missing function name in request" };
26+
return new Response(
27+
JSON.stringify(error),
28+
{ status: 400, headers: { "Content-Type": "application/json" } },
29+
);
30+
}
3131

32-
const servicePath = `./test_cases/${service_name}`;
33-
console.error(`serving the request with ${servicePath}`);
32+
const servicePath = `./test_cases/${service_name}`;
33+
console.error(`serving the request with ${servicePath}`);
3434

35-
const createWorker = async () => {
36-
const memoryLimitMb = parseIntFromHeadersOrDefault(
37-
req,
38-
'x-memory-limit-mb',
39-
150,
40-
);
41-
const workerTimeoutMs = parseIntFromHeadersOrDefault(
42-
req,
43-
'x-worker-timeout-ms',
44-
10 * 60 * 1000,
45-
);
46-
const cpuTimeSoftLimitMs = parseIntFromHeadersOrDefault(
47-
req,
48-
'x-cpu-time-soft-limit-ms',
49-
10 * 60 * 1000,
50-
);
51-
const cpuTimeHardLimitMs = parseIntFromHeadersOrDefault(
52-
req,
53-
'x-cpu-time-hard-limit-ms',
54-
10 * 60 * 1000,
55-
);
56-
const noModuleCache = false;
57-
const envVarsObj = Deno.env.toObject();
58-
const envVars = Object.keys(envVarsObj).map((k) => [k, envVarsObj[k]]);
59-
const context = {
60-
sourceMap: req.headers.get('x-context-source-map') == 'true',
61-
};
35+
const createWorker = async () => {
36+
const memoryLimitMb = parseIntFromHeadersOrDefault(
37+
req,
38+
"x-memory-limit-mb",
39+
150,
40+
);
41+
const workerTimeoutMs = parseIntFromHeadersOrDefault(
42+
req,
43+
"x-worker-timeout-ms",
44+
10 * 60 * 1000,
45+
);
46+
const cpuTimeSoftLimitMs = parseIntFromHeadersOrDefault(
47+
req,
48+
"x-cpu-time-soft-limit-ms",
49+
10 * 60 * 1000,
50+
);
51+
const cpuTimeHardLimitMs = parseIntFromHeadersOrDefault(
52+
req,
53+
"x-cpu-time-hard-limit-ms",
54+
10 * 60 * 1000,
55+
);
56+
const noModuleCache = false;
57+
const envVarsObj = Deno.env.toObject();
58+
const envVars = Object.keys(envVarsObj).map((k) => [k, envVarsObj[k]]);
59+
const context = {
60+
sourceMap: req.headers.get("x-context-source-map") == "true",
61+
};
6262

63-
return await EdgeRuntime.userWorkers.create({
64-
servicePath,
65-
memoryLimitMb,
66-
workerTimeoutMs,
67-
cpuTimeSoftLimitMs,
68-
cpuTimeHardLimitMs,
69-
noModuleCache,
70-
envVars,
71-
context,
72-
});
73-
};
63+
return await EdgeRuntime.userWorkers.create({
64+
servicePath,
65+
memoryLimitMb,
66+
workerTimeoutMs,
67+
cpuTimeSoftLimitMs,
68+
cpuTimeHardLimitMs,
69+
noModuleCache,
70+
envVars,
71+
context,
72+
});
73+
};
7474

75-
const callWorker = async () => {
76-
try {
77-
const worker = await createWorker();
78-
return await worker.fetch(req);
79-
} catch (e) {
80-
console.error(e);
75+
const callWorker = async () => {
76+
try {
77+
const worker = await createWorker();
78+
return await worker.fetch(req);
79+
} catch (e) {
80+
console.error(e);
8181

82-
// if (e instanceof Deno.errors.WorkerRequestCancelled) {
83-
// return await callWorker();
84-
// }
82+
// if (e instanceof Deno.errors.WorkerRequestCancelled) {
83+
// return await callWorker();
84+
// }
8585

86-
const error = { msg: e.toString() };
87-
return new Response(
88-
JSON.stringify(error),
89-
{ status: 500, headers: { 'Content-Type': 'application/json' } },
90-
);
91-
}
92-
};
86+
const error = { msg: e.toString() };
87+
return new Response(
88+
JSON.stringify(error),
89+
{ status: 500, headers: { "Content-Type": "application/json" } },
90+
);
91+
}
92+
};
9393

94-
return callWorker();
94+
return callWorker();
9595
});

0 commit comments

Comments
 (0)