From 19d7a349892f18c1d78e7096b7c09349142f7e00 Mon Sep 17 00:00:00 2001 From: Tim Neutkens Date: Wed, 2 Nov 2022 22:04:20 +0100 Subject: [PATCH 1/3] Ensure Undici is enabled for appDir in all cases --- packages/next/server/config.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/next/server/config.ts b/packages/next/server/config.ts index 6da832ea2c33..af9f3eb80e2f 100644 --- a/packages/next/server/config.ts +++ b/packages/next/server/config.ts @@ -65,9 +65,7 @@ export function setHttpClientAndAgentOptions(config: NextConfig) { ) } else { // When appDir is enabled undici is the default because of Response.clone() issues in node-fetch - ;(global as any).__NEXT_USE_UNDICI = config.experimental?.appDir - ? true - : config.experimental?.enableUndici + ;(global as any).__NEXT_USE_UNDICI = config.experimental?.enableUndici } } else if (config.experimental?.enableUndici) { Log.warn( @@ -260,6 +258,10 @@ function assignDefaults(dir: string, userConfig: { [key: string]: any }) { ) } + if (result.experimental?.appDir) { + result.experimental.enableUndici = true + } + if (result.basePath !== '') { if (result.basePath === '/') { throw new Error( From 1d176e68ef99d18c445def3de22952e91aa74615 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 2 Nov 2022 15:29:40 -0700 Subject: [PATCH 2/3] update test and initialize in server --- packages/next/server/next-server.ts | 3 + test/e2e/app-dir/app/api-server.js | 2087 ----------------- .../app/app/very-large-data-fetch/page.js | 6 +- test/e2e/app-dir/index.test.ts | 58 +- 4 files changed, 21 insertions(+), 2133 deletions(-) delete mode 100644 test/e2e/app-dir/app/api-server.js diff --git a/packages/next/server/next-server.ts b/packages/next/server/next-server.ts index d857cafb5510..44974e620d6d 100644 --- a/packages/next/server/next-server.ts +++ b/packages/next/server/next-server.ts @@ -99,6 +99,7 @@ import { IncrementalCache } from './lib/incremental-cache' import { normalizeAppPath } from '../shared/lib/router/utils/app-paths' import { renderToHTMLOrFlight as appRenderToHTMLOrFlight } from './app-render' +import { setHttpClientAndAgentOptions } from './config' export * from './base-server' @@ -260,6 +261,8 @@ export default class NextNodeServer extends BaseServer { const { AsyncLocalStorage } = require('async_hooks') ;(global as any).AsyncLocalStorage = AsyncLocalStorage } + // ensure options are set when loadConfig isn't called + setHttpClientAndAgentOptions(this.nextConfig) } private compression = this.nextConfig.compress diff --git a/test/e2e/app-dir/app/api-server.js b/test/e2e/app-dir/app/api-server.js deleted file mode 100644 index f256a412a4ac..000000000000 --- a/test/e2e/app-dir/app/api-server.js +++ /dev/null @@ -1,2087 +0,0 @@ -function largeData(_req, res) { - res.setHeader('Content-Type', 'application/json; charset=utf-8') - return res.end( - JSON.stringify({ - arrayOfObjects: [ - { - index: '0', - random: '5', - }, - { - index: '1', - 'index start at 5': '6', - }, - { - index: '2', - 'index start at 5': '7', - }, - { - index: '3', - 'index start at 5': '8', - }, - { - index: '4', - 'index start at 5': '9', - }, - { - index: '5', - 'index start at 5': '10', - }, - { - index: '6', - 'index start at 5': '11', - }, - { - index: '7', - 'index start at 5': '12', - }, - { - index: '8', - 'index start at 5': '13', - }, - { - index: '9', - 'index start at 5': '14', - }, - { - index: '10', - 'index start at 5': '15', - }, - { - index: '11', - 'index start at 5': '16', - }, - { - index: '12', - 'index start at 5': '17', - }, - { - index: '13', - 'index start at 5': '18', - }, - { - index: '14', - 'index start at 5': '19', - }, - { - index: '15', - 'index start at 5': '20', - }, - { - index: '16', - 'index start at 5': '21', - }, - { - index: '17', - 'index start at 5': '22', - }, - { - index: '18', - 'index start at 5': '23', - }, - { - index: '19', - 'index start at 5': '24', - }, - { - index: '20', - 'index start at 5': '25', - }, - { - index: '21', - 'index start at 5': '26', - }, - { - index: '22', - 'index start at 5': '27', - }, - { - index: '23', - 'index start at 5': '28', - }, - { - index: '24', - 'index start at 5': '29', - }, - { - index: '25', - 'index start at 5': '30', - }, - { - index: '26', - 'index start at 5': '31', - }, - { - index: '27', - 'index start at 5': '32', - }, - { - index: '28', - 'index start at 5': '33', - }, - { - index: '29', - 'index start at 5': '34', - }, - { - index: '30', - 'index start at 5': '35', - }, - { - index: '31', - 'index start at 5': '36', - }, - { - index: '32', - 'index start at 5': '37', - }, - { - index: '33', - 'index start at 5': '38', - }, - { - index: '34', - 'index start at 5': '39', - }, - { - index: '35', - 'index start at 5': '40', - }, - { - index: '36', - 'index start at 5': '41', - }, - { - index: '37', - 'index start at 5': '42', - }, - { - index: '38', - 'index start at 5': '43', - }, - { - index: '39', - 'index start at 5': '44', - }, - { - index: '40', - 'index start at 5': '45', - }, - { - index: '41', - 'index start at 5': '46', - }, - { - index: '42', - 'index start at 5': '47', - }, - { - index: '43', - 'index start at 5': '48', - }, - { - index: '44', - 'index start at 5': '49', - }, - { - index: '45', - 'index start at 5': '50', - }, - { - index: '46', - 'index start at 5': '51', - }, - { - index: '47', - 'index start at 5': '52', - }, - { - index: '48', - 'index start at 5': '53', - }, - { - index: '49', - 'index start at 5': '54', - }, - { - index: '50', - 'index start at 5': '55', - }, - { - index: '51', - 'index start at 5': '56', - }, - { - index: '52', - 'index start at 5': '57', - }, - { - index: '53', - 'index start at 5': '58', - }, - { - index: '54', - 'index start at 5': '59', - }, - { - index: '55', - 'index start at 5': '60', - }, - { - index: '56', - 'index start at 5': '61', - }, - { - index: '57', - 'index start at 5': '62', - }, - { - index: '58', - 'index start at 5': '63', - }, - { - index: '59', - 'index start at 5': '64', - }, - { - index: '60', - 'index start at 5': '65', - }, - { - index: '61', - 'index start at 5': '66', - }, - { - index: '62', - 'index start at 5': '67', - }, - { - index: '63', - 'index start at 5': '68', - }, - { - index: '64', - 'index start at 5': '69', - }, - { - index: '65', - 'index start at 5': '70', - }, - { - index: '66', - 'index start at 5': '71', - }, - { - index: '67', - 'index start at 5': '72', - }, - { - index: '68', - 'index start at 5': '73', - }, - { - index: '69', - 'index start at 5': '74', - }, - { - index: '70', - 'index start at 5': '75', - }, - { - index: '71', - 'index start at 5': '76', - }, - { - index: '72', - 'index start at 5': '77', - }, - { - index: '73', - 'index start at 5': '78', - }, - { - index: '74', - 'index start at 5': '79', - }, - { - index: '75', - 'index start at 5': '80', - }, - { - index: '76', - 'index start at 5': '81', - }, - { - index: '77', - 'index start at 5': '82', - }, - { - index: '78', - 'index start at 5': '83', - }, - { - index: '79', - 'index start at 5': '84', - }, - { - index: '80', - 'index start at 5': '85', - }, - { - index: '81', - 'index start at 5': '86', - }, - { - index: '82', - 'index start at 5': '87', - }, - { - index: '83', - 'index start at 5': '88', - }, - { - index: '84', - 'index start at 5': '89', - }, - { - index: '85', - 'index start at 5': '90', - }, - { - index: '86', - 'index start at 5': '91', - }, - { - index: '87', - 'index start at 5': '92', - }, - { - index: '88', - 'index start at 5': '93', - }, - { - index: '89', - 'index start at 5': '94', - }, - { - index: '90', - 'index start at 5': '95', - }, - { - index: '91', - 'index start at 5': '96', - }, - { - index: '92', - 'index start at 5': '97', - }, - { - index: '93', - 'index start at 5': '98', - }, - { - index: '94', - 'index start at 5': '99', - }, - { - index: '95', - 'index start at 5': '100', - }, - { - index: '96', - 'index start at 5': '101', - }, - { - index: '97', - 'index start at 5': '102', - }, - { - index: '98', - 'index start at 5': '103', - }, - { - index: '99', - 'index start at 5': '104', - }, - { - index: '100', - 'index start at 5': '105', - }, - { - index: '101', - 'index start at 5': '106', - }, - { - index: '102', - 'index start at 5': '107', - }, - { - index: '103', - 'index start at 5': '108', - }, - { - index: '104', - 'index start at 5': '109', - }, - { - index: '105', - 'index start at 5': '110', - }, - { - index: '106', - 'index start at 5': '111', - }, - { - index: '107', - 'index start at 5': '112', - }, - { - index: '108', - 'index start at 5': '113', - }, - { - index: '109', - 'index start at 5': '114', - }, - { - index: '110', - 'index start at 5': '115', - }, - { - index: '111', - 'index start at 5': '116', - }, - { - index: '112', - 'index start at 5': '117', - }, - { - index: '113', - 'index start at 5': '118', - }, - { - index: '114', - 'index start at 5': '119', - }, - { - index: '115', - 'index start at 5': '120', - }, - { - index: '116', - 'index start at 5': '121', - }, - { - index: '117', - 'index start at 5': '122', - }, - { - index: '118', - 'index start at 5': '123', - }, - { - index: '119', - 'index start at 5': '124', - }, - { - index: '120', - 'index start at 5': '125', - }, - { - index: '121', - 'index start at 5': '126', - }, - { - index: '122', - 'index start at 5': '127', - }, - { - index: '123', - 'index start at 5': '128', - }, - { - index: '124', - 'index start at 5': '129', - }, - { - index: '125', - 'index start at 5': '130', - }, - { - index: '126', - 'index start at 5': '131', - }, - { - index: '127', - 'index start at 5': '132', - }, - { - index: '128', - 'index start at 5': '133', - }, - { - index: '129', - 'index start at 5': '134', - }, - { - index: '130', - 'index start at 5': '135', - }, - { - index: '131', - 'index start at 5': '136', - }, - { - index: '132', - 'index start at 5': '137', - }, - { - index: '133', - 'index start at 5': '138', - }, - { - index: '134', - 'index start at 5': '139', - }, - { - index: '135', - 'index start at 5': '140', - }, - { - index: '136', - 'index start at 5': '141', - }, - { - index: '137', - 'index start at 5': '142', - }, - { - index: '138', - 'index start at 5': '143', - }, - { - index: '139', - 'index start at 5': '144', - }, - { - index: '140', - 'index start at 5': '145', - }, - { - index: '141', - 'index start at 5': '146', - }, - { - index: '142', - 'index start at 5': '147', - }, - { - index: '143', - 'index start at 5': '148', - }, - { - index: '144', - 'index start at 5': '149', - }, - { - index: '145', - 'index start at 5': '150', - }, - { - index: '146', - 'index start at 5': '151', - }, - { - index: '147', - 'index start at 5': '152', - }, - { - index: '148', - 'index start at 5': '153', - }, - { - index: '149', - 'index start at 5': '154', - }, - { - index: '150', - 'index start at 5': '155', - }, - { - index: '151', - 'index start at 5': '156', - }, - { - index: '152', - 'index start at 5': '157', - }, - { - index: '153', - 'index start at 5': '158', - }, - { - index: '154', - 'index start at 5': '159', - }, - { - index: '155', - 'index start at 5': '160', - }, - { - index: '156', - 'index start at 5': '161', - }, - { - index: '157', - 'index start at 5': '162', - }, - { - index: '158', - 'index start at 5': '163', - }, - { - index: '159', - 'index start at 5': '164', - }, - { - index: '160', - 'index start at 5': '165', - }, - { - index: '161', - 'index start at 5': '166', - }, - { - index: '162', - 'index start at 5': '167', - }, - { - index: '163', - 'index start at 5': '168', - }, - { - index: '164', - 'index start at 5': '169', - }, - { - index: '165', - 'index start at 5': '170', - }, - { - index: '166', - 'index start at 5': '171', - }, - { - index: '167', - 'index start at 5': '172', - }, - { - index: '168', - 'index start at 5': '173', - }, - { - index: '169', - 'index start at 5': '174', - }, - { - index: '170', - 'index start at 5': '175', - }, - { - index: '171', - 'index start at 5': '176', - }, - { - index: '172', - 'index start at 5': '177', - }, - { - index: '173', - 'index start at 5': '178', - }, - { - index: '174', - 'index start at 5': '179', - }, - { - index: '175', - 'index start at 5': '180', - }, - { - index: '176', - 'index start at 5': '181', - }, - { - index: '177', - 'index start at 5': '182', - }, - { - index: '178', - 'index start at 5': '183', - }, - { - index: '179', - 'index start at 5': '184', - }, - { - index: '180', - 'index start at 5': '185', - }, - { - index: '181', - 'index start at 5': '186', - }, - { - index: '182', - 'index start at 5': '187', - }, - { - index: '183', - 'index start at 5': '188', - }, - { - index: '184', - 'index start at 5': '189', - }, - { - index: '185', - 'index start at 5': '190', - }, - { - index: '186', - 'index start at 5': '191', - }, - { - index: '187', - 'index start at 5': '192', - }, - { - index: '188', - 'index start at 5': '193', - }, - { - index: '189', - 'index start at 5': '194', - }, - { - index: '190', - 'index start at 5': '195', - }, - { - index: '191', - 'index start at 5': '196', - }, - { - index: '192', - 'index start at 5': '197', - }, - { - index: '193', - 'index start at 5': '198', - }, - { - index: '194', - 'index start at 5': '199', - }, - { - index: '195', - 'index start at 5': '200', - }, - { - index: '196', - 'index start at 5': '201', - }, - { - index: '197', - 'index start at 5': '202', - }, - { - index: '198', - 'index start at 5': '203', - }, - { - index: '199', - 'index start at 5': '204', - }, - { - index: '200', - 'index start at 5': '205', - }, - { - index: '201', - 'index start at 5': '206', - }, - { - index: '202', - 'index start at 5': '207', - }, - { - index: '203', - 'index start at 5': '208', - }, - { - index: '204', - 'index start at 5': '209', - }, - { - index: '205', - 'index start at 5': '210', - }, - { - index: '206', - 'index start at 5': '211', - }, - { - index: '207', - 'index start at 5': '212', - }, - { - index: '208', - 'index start at 5': '213', - }, - { - index: '209', - 'index start at 5': '214', - }, - { - index: '210', - 'index start at 5': '215', - }, - { - index: '211', - 'index start at 5': '216', - }, - { - index: '212', - 'index start at 5': '217', - }, - { - index: '213', - 'index start at 5': '218', - }, - { - index: '214', - 'index start at 5': '219', - }, - { - index: '215', - 'index start at 5': '220', - }, - { - index: '216', - 'index start at 5': '221', - }, - { - index: '217', - 'index start at 5': '222', - }, - { - index: '218', - 'index start at 5': '223', - }, - { - index: '219', - 'index start at 5': '224', - }, - { - index: '220', - 'index start at 5': '225', - }, - { - index: '221', - 'index start at 5': '226', - }, - { - index: '222', - 'index start at 5': '227', - }, - { - index: '223', - 'index start at 5': '228', - }, - { - index: '224', - 'index start at 5': '229', - }, - { - index: '225', - 'index start at 5': '230', - }, - { - index: '226', - 'index start at 5': '231', - }, - { - index: '227', - 'index start at 5': '232', - }, - { - index: '228', - 'index start at 5': '233', - }, - { - index: '229', - 'index start at 5': '234', - }, - { - index: '230', - 'index start at 5': '235', - }, - { - index: '231', - 'index start at 5': '236', - }, - { - index: '232', - 'index start at 5': '237', - }, - { - index: '233', - 'index start at 5': '238', - }, - { - index: '234', - 'index start at 5': '239', - }, - { - index: '235', - 'index start at 5': '240', - }, - { - index: '236', - 'index start at 5': '241', - }, - { - index: '237', - 'index start at 5': '242', - }, - { - index: '238', - 'index start at 5': '243', - }, - { - index: '239', - 'index start at 5': '244', - }, - { - index: '240', - 'index start at 5': '245', - }, - { - index: '241', - 'index start at 5': '246', - }, - { - index: '242', - 'index start at 5': '247', - }, - { - index: '243', - 'index start at 5': '248', - }, - { - index: '244', - 'index start at 5': '249', - }, - { - index: '245', - 'index start at 5': '250', - }, - { - index: '246', - 'index start at 5': '251', - }, - { - index: '247', - 'index start at 5': '252', - }, - { - index: '248', - 'index start at 5': '253', - }, - { - index: '249', - 'index start at 5': '254', - }, - { - index: '250', - 'index start at 5': '255', - }, - { - index: '251', - 'index start at 5': '256', - }, - { - index: '252', - 'index start at 5': '257', - }, - { - index: '253', - 'index start at 5': '258', - }, - { - index: '254', - 'index start at 5': '259', - }, - { - index: '255', - 'index start at 5': '260', - }, - { - index: '256', - 'index start at 5': '261', - }, - { - index: '257', - 'index start at 5': '262', - }, - { - index: '258', - 'index start at 5': '263', - }, - { - index: '259', - 'index start at 5': '264', - }, - { - index: '260', - 'index start at 5': '265', - }, - { - index: '261', - 'index start at 5': '266', - }, - { - index: '262', - 'index start at 5': '267', - }, - { - index: '263', - 'index start at 5': '268', - }, - { - index: '264', - 'index start at 5': '269', - }, - { - index: '265', - 'index start at 5': '270', - }, - { - index: '266', - 'index start at 5': '271', - }, - { - index: '267', - 'index start at 5': '272', - }, - { - index: '268', - 'index start at 5': '273', - }, - { - index: '269', - 'index start at 5': '274', - }, - { - index: '270', - 'index start at 5': '275', - }, - { - index: '271', - 'index start at 5': '276', - }, - { - index: '272', - 'index start at 5': '277', - }, - { - index: '273', - 'index start at 5': '278', - }, - { - index: '274', - 'index start at 5': '279', - }, - { - index: '275', - 'index start at 5': '280', - }, - { - index: '276', - 'index start at 5': '281', - }, - { - index: '277', - 'index start at 5': '282', - }, - { - index: '278', - 'index start at 5': '283', - }, - { - index: '279', - 'index start at 5': '284', - }, - { - index: '280', - 'index start at 5': '285', - }, - { - index: '281', - 'index start at 5': '286', - }, - { - index: '282', - 'index start at 5': '287', - }, - { - index: '283', - 'index start at 5': '288', - }, - { - index: '284', - 'index start at 5': '289', - }, - { - index: '285', - 'index start at 5': '290', - }, - { - index: '286', - 'index start at 5': '291', - }, - { - index: '287', - 'index start at 5': '292', - }, - { - index: '288', - 'index start at 5': '293', - }, - { - index: '289', - 'index start at 5': '294', - }, - { - index: '290', - 'index start at 5': '295', - }, - { - index: '291', - 'index start at 5': '296', - }, - { - index: '292', - 'index start at 5': '297', - }, - { - index: '293', - 'index start at 5': '298', - }, - { - index: '294', - 'index start at 5': '299', - }, - { - index: '295', - 'index start at 5': '300', - }, - { - index: '296', - 'index start at 5': '301', - }, - { - index: '297', - 'index start at 5': '302', - }, - { - index: '298', - 'index start at 5': '303', - }, - { - index: '299', - 'index start at 5': '304', - }, - { - index: '300', - 'index start at 5': '305', - }, - { - index: '301', - 'index start at 5': '306', - }, - { - index: '302', - 'index start at 5': '307', - }, - { - index: '303', - 'index start at 5': '308', - }, - { - index: '304', - 'index start at 5': '309', - }, - { - index: '305', - 'index start at 5': '310', - }, - { - index: '306', - 'index start at 5': '311', - }, - { - index: '307', - 'index start at 5': '312', - }, - { - index: '308', - 'index start at 5': '313', - }, - { - index: '309', - 'index start at 5': '314', - }, - { - index: '310', - 'index start at 5': '315', - }, - { - index: '311', - 'index start at 5': '316', - }, - { - index: '312', - 'index start at 5': '317', - }, - { - index: '313', - 'index start at 5': '318', - }, - { - index: '314', - 'index start at 5': '319', - }, - { - index: '315', - 'index start at 5': '320', - }, - { - index: '316', - 'index start at 5': '321', - }, - { - index: '317', - 'index start at 5': '322', - }, - { - index: '318', - 'index start at 5': '323', - }, - { - index: '319', - 'index start at 5': '324', - }, - { - index: '320', - 'index start at 5': '325', - }, - { - index: '321', - 'index start at 5': '326', - }, - { - index: '322', - 'index start at 5': '327', - }, - { - index: '323', - 'index start at 5': '328', - }, - { - index: '324', - 'index start at 5': '329', - }, - { - index: '325', - 'index start at 5': '330', - }, - { - index: '326', - 'index start at 5': '331', - }, - { - index: '327', - 'index start at 5': '332', - }, - { - index: '328', - 'index start at 5': '333', - }, - { - index: '329', - 'index start at 5': '334', - }, - { - index: '330', - 'index start at 5': '335', - }, - { - index: '331', - 'index start at 5': '336', - }, - { - index: '332', - 'index start at 5': '337', - }, - { - index: '333', - 'index start at 5': '338', - }, - { - index: '334', - 'index start at 5': '339', - }, - { - index: '335', - 'index start at 5': '340', - }, - { - index: '336', - 'index start at 5': '341', - }, - { - index: '337', - 'index start at 5': '342', - }, - { - index: '338', - 'index start at 5': '343', - }, - { - index: '339', - 'index start at 5': '344', - }, - { - index: '340', - 'index start at 5': '345', - }, - { - index: '341', - 'index start at 5': '346', - }, - { - index: '342', - 'index start at 5': '347', - }, - { - index: '343', - 'index start at 5': '348', - }, - { - index: '344', - 'index start at 5': '349', - }, - { - index: '345', - 'index start at 5': '350', - }, - { - index: '346', - 'index start at 5': '351', - }, - { - index: '347', - 'index start at 5': '352', - }, - { - index: '348', - 'index start at 5': '353', - }, - { - index: '349', - 'index start at 5': '354', - }, - { - index: '294', - 'index start at 5': '299', - }, - { - index: '295', - 'index start at 5': '300', - }, - { - index: '296', - 'index start at 5': '301', - }, - { - index: '297', - 'index start at 5': '302', - }, - { - index: '298', - 'index start at 5': '303', - }, - { - index: '299', - 'index start at 5': '304', - }, - { - index: '300', - 'index start at 5': '305', - }, - { - index: '301', - 'index start at 5': '306', - }, - { - index: '302', - 'index start at 5': '307', - }, - { - index: '303', - 'index start at 5': '308', - }, - { - index: '304', - 'index start at 5': '309', - }, - { - index: '305', - 'index start at 5': '310', - }, - { - index: '306', - 'index start at 5': '311', - }, - { - index: '307', - 'index start at 5': '312', - }, - { - index: '308', - 'index start at 5': '313', - }, - { - index: '309', - 'index start at 5': '314', - }, - { - index: '310', - 'index start at 5': '315', - }, - { - index: '311', - 'index start at 5': '316', - }, - { - index: '312', - 'index start at 5': '317', - }, - { - index: '313', - 'index start at 5': '318', - }, - { - index: '314', - 'index start at 5': '319', - }, - { - index: '315', - 'index start at 5': '320', - }, - { - index: '316', - 'index start at 5': '321', - }, - { - index: '317', - 'index start at 5': '322', - }, - { - index: '318', - 'index start at 5': '323', - }, - { - index: '319', - 'index start at 5': '324', - }, - { - index: '320', - 'index start at 5': '325', - }, - { - index: '321', - 'index start at 5': '326', - }, - { - index: '322', - 'index start at 5': '327', - }, - { - index: '323', - 'index start at 5': '328', - }, - { - index: '324', - 'index start at 5': '329', - }, - { - index: '325', - 'index start at 5': '330', - }, - { - index: '326', - 'index start at 5': '331', - }, - { - index: '327', - 'index start at 5': '332', - }, - { - index: '328', - 'index start at 5': '333', - }, - { - index: '329', - 'index start at 5': '334', - }, - { - index: '330', - 'index start at 5': '335', - }, - { - index: '331', - 'index start at 5': '336', - }, - { - index: '332', - 'index start at 5': '337', - }, - { - index: '333', - 'index start at 5': '338', - }, - { - index: '334', - 'index start at 5': '339', - }, - { - index: '335', - 'index start at 5': '340', - }, - { - index: '336', - 'index start at 5': '341', - }, - { - index: '337', - 'index start at 5': '342', - }, - { - index: '338', - 'index start at 5': '343', - }, - { - index: '339', - 'index start at 5': '344', - }, - { - index: '340', - 'index start at 5': '345', - }, - { - index: '341', - 'index start at 5': '346', - }, - { - index: '342', - 'index start at 5': '347', - }, - { - index: '343', - 'index start at 5': '348', - }, - { - index: '344', - 'index start at 5': '349', - }, - { - index: '345', - 'index start at 5': '350', - }, - { - index: '346', - 'index start at 5': '351', - }, - { - index: '347', - 'index start at 5': '352', - }, - { - index: '348', - 'index start at 5': '353', - }, - { - index: '349', - 'index start at 5': '354', - }, - { - index: '294', - 'index start at 5': '299', - }, - { - index: '295', - 'index start at 5': '300', - }, - { - index: '296', - 'index start at 5': '301', - }, - { - index: '297', - 'index start at 5': '302', - }, - { - index: '298', - 'index start at 5': '303', - }, - { - index: '299', - 'index start at 5': '304', - }, - { - index: '300', - 'index start at 5': '305', - }, - { - index: '301', - 'index start at 5': '306', - }, - { - index: '302', - 'index start at 5': '307', - }, - { - index: '303', - 'index start at 5': '308', - }, - { - index: '304', - 'index start at 5': '309', - }, - { - index: '305', - 'index start at 5': '310', - }, - { - index: '306', - 'index start at 5': '311', - }, - { - index: '307', - 'index start at 5': '312', - }, - { - index: '308', - 'index start at 5': '313', - }, - { - index: '309', - 'index start at 5': '314', - }, - { - index: '310', - 'index start at 5': '315', - }, - { - index: '311', - 'index start at 5': '316', - }, - { - index: '312', - 'index start at 5': '317', - }, - { - index: '313', - 'index start at 5': '318', - }, - { - index: '314', - 'index start at 5': '319', - }, - { - index: '315', - 'index start at 5': '320', - }, - { - index: '316', - 'index start at 5': '321', - }, - { - index: '317', - 'index start at 5': '322', - }, - { - index: '318', - 'index start at 5': '323', - }, - { - index: '319', - 'index start at 5': '324', - }, - { - index: '320', - 'index start at 5': '325', - }, - { - index: '321', - 'index start at 5': '326', - }, - { - index: '322', - 'index start at 5': '327', - }, - { - index: '323', - 'index start at 5': '328', - }, - { - index: '324', - 'index start at 5': '329', - }, - { - index: '325', - 'index start at 5': '330', - }, - { - index: '326', - 'index start at 5': '331', - }, - { - index: '327', - 'index start at 5': '332', - }, - { - index: '328', - 'index start at 5': '333', - }, - { - index: '329', - 'index start at 5': '334', - }, - { - index: '330', - 'index start at 5': '335', - }, - { - index: '331', - 'index start at 5': '336', - }, - { - index: '332', - 'index start at 5': '337', - }, - { - index: '333', - 'index start at 5': '338', - }, - { - index: '334', - 'index start at 5': '339', - }, - { - index: '335', - 'index start at 5': '340', - }, - { - index: '336', - 'index start at 5': '341', - }, - { - index: '337', - 'index start at 5': '342', - }, - { - index: '338', - 'index start at 5': '343', - }, - { - index: '339', - 'index start at 5': '344', - }, - { - index: '340', - 'index start at 5': '345', - }, - { - index: '341', - 'index start at 5': '346', - }, - { - index: '342', - 'index start at 5': '347', - }, - { - index: '343', - 'index start at 5': '348', - }, - { - index: '344', - 'index start at 5': '349', - }, - { - index: '345', - 'index start at 5': '350', - }, - { - index: '346', - 'index start at 5': '351', - }, - { - index: '347', - 'index start at 5': '352', - }, - { - index: '348', - 'index start at 5': '353', - }, - { - index: '349', - 'index start at 5': '354', - }, - { - index: '294', - 'index start at 5': '299', - }, - { - index: '295', - 'index start at 5': '300', - }, - { - index: '296', - 'index start at 5': '301', - }, - { - index: '297', - 'index start at 5': '302', - }, - { - index: '298', - 'index start at 5': '303', - }, - { - index: '299', - 'index start at 5': '304', - }, - { - index: '300', - 'index start at 5': '305', - }, - { - index: '301', - 'index start at 5': '306', - }, - { - index: '302', - 'index start at 5': '307', - }, - { - index: '303', - 'index start at 5': '308', - }, - { - index: '304', - 'index start at 5': '309', - }, - { - index: '305', - 'index start at 5': '310', - }, - { - index: '306', - 'index start at 5': '311', - }, - { - index: '307', - 'index start at 5': '312', - }, - { - index: '308', - 'index start at 5': '313', - }, - { - index: '309', - 'index start at 5': '314', - }, - { - index: '310', - 'index start at 5': '315', - }, - { - index: '311', - 'index start at 5': '316', - }, - { - index: '312', - 'index start at 5': '317', - }, - { - index: '313', - 'index start at 5': '318', - }, - { - index: '314', - 'index start at 5': '319', - }, - { - index: '315', - 'index start at 5': '320', - }, - { - index: '316', - 'index start at 5': '321', - }, - { - index: '317', - 'index start at 5': '322', - }, - { - index: '318', - 'index start at 5': '323', - }, - { - index: '319', - 'index start at 5': '324', - }, - { - index: '320', - 'index start at 5': '325', - }, - { - index: '321', - 'index start at 5': '326', - }, - { - index: '322', - 'index start at 5': '327', - }, - { - index: '323', - 'index start at 5': '328', - }, - { - index: '324', - 'index start at 5': '329', - }, - { - index: '325', - 'index start at 5': '330', - }, - { - index: '326', - 'index start at 5': '331', - }, - { - index: '327', - 'index start at 5': '332', - }, - { - index: '328', - 'index start at 5': '333', - }, - { - index: '329', - 'index start at 5': '334', - }, - { - index: '330', - 'index start at 5': '335', - }, - { - index: '331', - 'index start at 5': '336', - }, - { - index: '332', - 'index start at 5': '337', - }, - { - index: '333', - 'index start at 5': '338', - }, - { - index: '334', - 'index start at 5': '339', - }, - { - index: '335', - 'index start at 5': '340', - }, - { - index: '336', - 'index start at 5': '341', - }, - { - index: '337', - 'index start at 5': '342', - }, - { - index: '338', - 'index start at 5': '343', - }, - { - index: '339', - 'index start at 5': '344', - }, - { - index: '340', - 'index start at 5': '345', - }, - { - index: '341', - 'index start at 5': '346', - }, - { - index: '342', - 'index start at 5': '347', - }, - { - index: '343', - 'index start at 5': '348', - }, - { - index: '344', - 'index start at 5': '349', - }, - { - index: '345', - 'index start at 5': '350', - }, - { - index: '346', - 'index start at 5': '351', - }, - { - index: '347', - 'index start at 5': '352', - }, - { - index: '348', - 'index start at 5': '353', - }, - { - index: '349', - 'index start at 5': '354', - }, - ], - }) - ) -} - -const server = require('http').Server(largeData) - -server.listen(process.env.PORT || 3000, () => { - console.log('Listening on port 3000') -}) diff --git a/test/e2e/app-dir/app/app/very-large-data-fetch/page.js b/test/e2e/app-dir/app/app/very-large-data-fetch/page.js index 8bd01d09ef96..41b228f45929 100644 --- a/test/e2e/app-dir/app/app/very-large-data-fetch/page.js +++ b/test/e2e/app-dir/app/app/very-large-data-fetch/page.js @@ -1,16 +1,14 @@ export default async function Home() { const res = await fetch( - `http://localhost:${process.env.API_SERVER_PORT || 3000}/api/large-data` + `https://data-api-endpoint-nmw78dd69-ijjk-testing.vercel.app/api/data?amount=128000` ) const resClone = res.clone() const json = await resClone.json() - const firstItem = json.arrayOfObjects[0] return ( <>

Hello world

-

{firstItem.index}

-

{firstItem.random}

+

item count {json.data.length}

) } diff --git a/test/e2e/app-dir/index.test.ts b/test/e2e/app-dir/index.test.ts index b589356462ee..02b64140afe3 100644 --- a/test/e2e/app-dir/index.test.ts +++ b/test/e2e/app-dir/index.test.ts @@ -7,8 +7,6 @@ import { findPort, getRedboxHeader, hasRedbox, - initNextServerScript, - killApp, renderViaHTTP, waitFor, } from 'next-test-utils' @@ -19,13 +17,9 @@ import webdriver from 'next-webdriver' describe('app dir', () => { const isDev = (global as any).isNextDev let next: NextInstance - let apiServerPort: number - let apiInstance: any function runTests() { beforeAll(async () => { - apiServerPort = await findPort() - next = await createNext({ files: new FileRef(path.join(__dirname, 'app')), dependencies: { @@ -34,25 +28,10 @@ describe('app dir', () => { 'react-dom': 'latest', sass: 'latest', }, - env: { - API_SERVER_PORT: apiServerPort.toString(), - }, - skipStart: true, }) - - apiInstance = await initNextServerScript( - path.join(__dirname, 'app', 'api-server.js'), - /Listening on/, - { ...process.env, PORT: apiServerPort }, - undefined, - { cwd: next.testDir } - ) - - await next.start() }) - afterAll(() => { - next.destroy() - killApp(apiInstance) + afterAll(async () => { + await next.destroy() }) if (!(global as any).isNextDeploy) { @@ -292,10 +271,13 @@ describe('app dir', () => { ) }) - it('should serve page as a segment name correctly', async () => { - const html = await renderViaHTTP(next.url, '/dashboard/page') - expect(html).toContain('hello dashboard/page!') - }) + // TODO-APP: fix to ensure behavior matches on deploy + if (!(global as any).isNextDeploy) { + it('should serve page as a segment name correctly', async () => { + const html = await renderViaHTTP(next.url, '/dashboard/page') + expect(html).toContain('hello dashboard/page!') + }) + } it('should include document html and body', async () => { const html = await renderViaHTTP(next.url, '/dashboard') @@ -2265,21 +2247,13 @@ describe('app dir', () => { }) describe('data fetch with response over 16KB with chunked encoding', () => { - // TODO-APP: increase timeouts for testing against deploy? - if (!(global as any).isNextDeploy) { - it('should load page when fetching a large amount of data', async () => { - const browser = await webdriver(next.url, '/very-large-data-fetch') - expect( - await (await browser.waitForElementByCss('#done', 5000)).text() - ).toBe('Hello world') - expect( - await (await browser.waitForElementByCss('#index', 2000)).text() - ).toBe('0') - expect( - await (await browser.waitForElementByCss('#random', 2000)).text() - ).toBe('5') - }) - } + it('should load page when fetching a large amount of data', async () => { + const browser = await webdriver(next.url, '/very-large-data-fetch') + expect(await (await browser.waitForElementByCss('#done')).text()).toBe( + 'Hello world' + ) + expect(await browser.elementByCss('p').text()).toBe('item count 128000') + }) }) } From e6323832bfeecccc85c3080dd849dca819eea0e5 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 2 Nov 2022 16:07:48 -0700 Subject: [PATCH 3/3] lint fix --- test/e2e/app-dir/index.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/e2e/app-dir/index.test.ts b/test/e2e/app-dir/index.test.ts index 02b64140afe3..b76cdd46ede4 100644 --- a/test/e2e/app-dir/index.test.ts +++ b/test/e2e/app-dir/index.test.ts @@ -4,7 +4,6 @@ import { NextInstance } from 'test/lib/next-modes/base' import { check, fetchViaHTTP, - findPort, getRedboxHeader, hasRedbox, renderViaHTTP,