From 107ba10626c6f028ef5341a794f5acaf748d3efd Mon Sep 17 00:00:00 2001 From: Matt Mastracci Date: Wed, 19 Jul 2023 12:43:49 -0600 Subject: [PATCH] fix(ext/http): Error on deprecated/unavailable features (#19880) Throws an error when user code attempts to use unsupported options (may help reduce confusion when migrating to Deno.serve) --- ext/http/00_serve.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ext/http/00_serve.js b/ext/http/00_serve.js index 95079f4128..e881cca2a3 100644 --- a/ext/http/00_serve.js +++ b/ext/http/00_serve.js @@ -627,6 +627,17 @@ function serve(arg1, arg2) { reusePort: options.reusePort ?? false, }; + if (options.certFile || options.keyFile) { + throw new TypeError( + "Unsupported 'certFile' / 'keyFile' options provided: use 'cert' / 'key' instead.", + ); + } + if (options.alpnProtocols) { + throw new TypeError( + "Unsupported 'alpnProtocols' option provided. 'h2' and 'http/1.1' are automatically supported.", + ); + } + let listener; if (wantsHttps) { if (!options.cert || !options.key) {