-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[EDU-2609] feat: cells node compatibility (#451)
* add compatibility cells-node page * adjustments * remove duplicate * cells-node compatibility * Update src/content/docs/en/pages/devtools/azion-edge-runtime/compatibility/cells-node.mdx Co-authored-by: hannah <[email protected]> * Update src/i18n/en/runtimeMenu.ts * Update src/content/docs/en/pages/devtools/azion-edge-runtime/compatibility/cells-node.mdx Co-authored-by: Mariana Bellorín Aguilera <[email protected]> --------- Co-authored-by: hannah <[email protected]> Co-authored-by: Mariana Bellorín Aguilera <[email protected]>
- Loading branch information
1 parent
725dda0
commit e6de7bd
Showing
3 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
src/content/docs/en/pages/devtools/azion-edge-runtime/compatibility/cells-node.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
--- | ||
title: Azion Edge Runtime and Node.js compatibility | ||
description: Azion Edge Runtime and Node.js compatibility | ||
meta_tags: edge, javascript | ||
namespace: documentation_products_azion_runtime_node | ||
permalink: /documentation/products/azion-edge-runtime/compatibility/node/ | ||
menu_namespace: runtimeMenu | ||
--- | ||
|
||
import Button from '~/components/Button.astro' | ||
|
||
The compatibility between **Azion Edge Runtime** and **Node.js** is an ongoing task, but a set of Node Runtime APIs are listed and are compatible with Azion Edge Runtime. | ||
|
||
The compatibility is listed below: | ||
|
||
## Node built-in | ||
|
||
### [async_hooks](https://nodejs.org/api/async_hooks.html) | ||
|
||
**Supported**: 🟡 Partially supported | ||
|
||
**Comments**: only [AsyncLocalStorage](https://nodejs.org/api/async_context.html#class-asynclocalstorage) and [AsyncResource](https://nodejs.org/api/async_hooks.html#class-asyncresource) are implemented. | ||
|
||
**Example**: | ||
|
||
```javascript | ||
import { AsyncLocalStorage } from "node:async_hooks"; | ||
|
||
const requestId = new AsyncLocalStorage(); | ||
|
||
async function logAsyncContext(state) { | ||
console.log(`${requestId.getStore()} - ${state}`); | ||
} | ||
|
||
async function doSomething() { | ||
logAsyncContext("log from async function"); | ||
doSomethingElse(); | ||
} | ||
|
||
async function doSomethingElse() { | ||
logAsyncContext("log from another async function"); | ||
} | ||
|
||
async function handleRequest(request) { | ||
const id = request.headers.get("X-Request-Id"); | ||
|
||
return requestId.run(id, async () => { | ||
doSomething(); | ||
logAsyncContext("log from yet another async function"); | ||
requestId.exit(async () => { | ||
logAsyncContext("log from exit callback"); | ||
}); | ||
return new Response("ok"); | ||
}); | ||
} | ||
|
||
addEventListener("fetch", (event) => { | ||
event.respondWith(handleRequest(event.request)); | ||
}); | ||
``` | ||
|
||
For additional compatibility information: | ||
|
||
<Button href="/en/documentation/products/edge-application/edge-functions/runtime-apis/javascript/" text="go to supported Web APIs" variant="secondary" target="_blank"></Button> | ||
<br /> | ||
<Button href="/en/documentation/products/devtools/azion-edge-runtime/frameworks-compatibility/" text="go to supported Web Frameworks" variant="secondary" target="_blank"></Button> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters