From d325837c2e1193c175dae2b3a5958bc4b4a7fa91 Mon Sep 17 00:00:00 2001 From: Daniel Nalborczyk Date: Fri, 22 Jul 2022 14:13:38 -0400 Subject: [PATCH] fix: remove replay --- src/events/http/HttpServer.js | 39 +---------------------------------- 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/src/events/http/HttpServer.js b/src/events/http/HttpServer.js index 15a62f8d6..0c7843b9b 100644 --- a/src/events/http/HttpServer.js +++ b/src/events/http/HttpServer.js @@ -2,7 +2,7 @@ import { Buffer } from 'node:buffer' import { readFileSync } from 'node:fs' import { createRequire } from 'node:module' import { join, resolve } from 'node:path' -import process, { exit } from 'node:process' +import { exit } from 'node:process' import h2o2 from '@hapi/h2o2' import { Server } from '@hapi/hapi' import { log } from '@serverless/utils/log.js' @@ -35,8 +35,6 @@ const { assign, entries, keys } = Object export default class HttpServer { #lambda = null - #lastRequestOptions = null - #options = null #serverless = null @@ -200,14 +198,10 @@ export default class HttpServer { log.notice(`Server ready: ${server} 🚀`) log.notice() log.notice('Enter "rp" to replay the last request') - - process.stdin.addListener('data', this.#handleStdin) } // stops the server stop(timeout) { - process.stdin.removeListener('data', this.#handleStdin) - process.stdin.pause() return this.#server.stop({ timeout, }) @@ -221,15 +215,6 @@ export default class HttpServer { } } - #handleStdin = (data) => { - // note: data is an object, and when converted to a string it will - // end with a linefeed. so we (rather crudely) account for that - // with toString() and then trim() - if (data.toString().trim() === 'rp') { - this.#injectLastRequest() - } - } - #logPluginIssue() { log.notice( 'If you think this is an issue with the plugin please submit it, thanks!\nhttps://github.com/dherault/serverless-offline/issues', @@ -517,24 +502,11 @@ export default class HttpServer { hapiOptions.tags = ['api'] const hapiHandler = async (request, h) => { - // Here we go - // Store current request as the last one - this.#lastRequestOptions = { - headers: request.headers, - method: request.method, - payload: request.payload, - url: request.url.href, - } - const requestPath = endpoint.isHttpApi || this.#options.noPrependStageInUrl ? request.path : request.path.substr(`/${stage}`.length) - if (request.auth.credentials && request.auth.strategy) { - this.#lastRequestOptions.auth = request.auth - } - // Payload processing const encoding = detectEncoding(request) @@ -1261,15 +1233,6 @@ export default class HttpServer { .map((line) => line.trim()) } - #injectLastRequest() { - if (this.#lastRequestOptions) { - log.notice('Replaying HTTP last request') - this.#server.inject(this.#lastRequestOptions) - } else { - log.notice('No last HTTP request to replay!') - } - } - writeRoutesTerminal() { logRoutes(this.#terminalInfo) }