Skip to content

Modules: improved handling of results of async handlers.#984

Merged
VadimZhestikov merged 2 commits into
nginx:masterfrom
VadimZhestikov:handling-results-async-handlers-2
Nov 6, 2025
Merged

Modules: improved handling of results of async handlers.#984
VadimZhestikov merged 2 commits into
nginx:masterfrom
VadimZhestikov:handling-results-async-handlers-2

Conversation

@VadimZhestikov
Copy link
Copy Markdown
Contributor

No description provided.

@VadimZhestikov VadimZhestikov force-pushed the handling-results-async-handlers-2 branch from ac6576b to 9b23492 Compare November 5, 2025 16:36
@VadimZhestikov VadimZhestikov changed the title Handling results async handlers 2 Modules: improved handling of results of async handlers. Nov 5, 2025
@VadimZhestikov VadimZhestikov force-pushed the handling-results-async-handlers-2 branch 5 times, most recently from fc02e4d to 78e2f82 Compare November 5, 2025 20:52
xeioex

This comment was marked as resolved.

Comment thread nginx/ngx_js.c Outdated
Comment thread external/njs_shell.c Outdated
@VadimZhestikov VadimZhestikov force-pushed the handling-results-async-handlers-2 branch from 78e2f82 to b1100e3 Compare November 6, 2025 01:19
@VadimZhestikov VadimZhestikov force-pushed the handling-results-async-handlers-2 branch from b1100e3 to 07c5b42 Compare November 6, 2025 18:14
xeioex

This comment was marked as resolved.

@VadimZhestikov VadimZhestikov force-pushed the handling-results-async-handlers-2 branch from 07c5b42 to 248db56 Compare November 6, 2025 22:12
@VadimZhestikov VadimZhestikov requested a review from xeioex November 6, 2025 22:21
xeioex

This comment was marked as resolved.

Previously, r.setReturnValue() had to be used when returning a value from async js_set handler.

async function hash(r) {
    let hash = await crypto.subtle.digest('SHA-512', r.headersIn.host);
    r.setReturnValue(Buffer.from(hash).toString('hex'));
}

Now r.setReturnValue() is not needed:

async function hash(r) {
    let hash = await crypto.subtle.digest('SHA-512', r.headersIn.host);
    return Buffer.from(hash).toString('hex');
}

Also added promise handling in global qjs code.
@VadimZhestikov VadimZhestikov force-pushed the handling-results-async-handlers-2 branch from 248db56 to 6b6934f Compare November 6, 2025 22:29
@VadimZhestikov VadimZhestikov requested a review from xeioex November 6, 2025 22:30
Copy link
Copy Markdown
Contributor

@xeioex xeioex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@VadimZhestikov VadimZhestikov merged commit 69514db into nginx:master Nov 6, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants