suppressConnectErrors now prints a warning

Renames suppressExpressErrors to _suppressExpressErrors as it should not be part of the public API, except for testing
This commit is contained in:
filipenevola
2023-11-11 11:52:20 -05:00
parent e366886747
commit 4a3afb4eef
3 changed files with 17 additions and 5 deletions

View File

@@ -467,7 +467,7 @@ if (Meteor.isServer) {
function (test, expect) {
// Suppress error printing for this test (and for any other code that sets
// the x-suppress-error header).
WebApp.suppressExpressErrors();
WebApp._suppressExpressErrors();
function do_test (path, code, match) {
const prefix = Meteor.isModern

View File

@@ -36,10 +36,14 @@ export declare module WebApp {
var httpServer: http.Server;
var expressApp: express.Application;
/**
* @deprecated use suppressExpressErrors instead
* Should be used only for testing
* @deprecated use _suppressExpressErrors instead
*/
function suppressConnectErrors(): void;
function suppressExpressErrors(): void;
/**
* Should be used only for testing
*/
function _suppressExpressErrors(): void;
function onListening(callback: Function): void;
type RuntimeConfigHookCallback = (options: {

View File

@@ -1349,6 +1349,8 @@ async function runWebAppServer() {
suppressExpressErrors = true;
};
let warnedAboutConnectUsage = false;
// start up app
_.extend(WebApp, {
connectHandlers: packageAndAppHandlers,
@@ -1358,8 +1360,14 @@ async function runWebAppServer() {
httpServer: httpServer,
expressApp: app,
// For testing.
suppressConnectErrors: suppressErrors,
suppressExpressErrors: suppressErrors,
suppressConnectErrors: () => {
if (! warnedAboutConnectUsage) {
Meteor._debug("WebApp.suppressConnectErrors has been renamed to Meteor._suppressExpressErrors and it should be used only in tests.");
warnedAboutConnectUsage = true;
}
suppressErrors();
},
_suppressExpressErrors: suppressErrors,
onListening: function(f) {
if (onListeningCallbacks) onListeningCallbacks.push(f);
else f();