mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Update dependencies
Summary: Changes the minimum version of Node to 18, and updates the Docker images and GitHub workflows to build Grist with Node 18. Also updates various dependencies and scripts to support building running tests with arm64 builds of Node. Test Plan: Existing tests. Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D3968
This commit is contained in:
@@ -278,37 +278,49 @@ describe('Comm', function() {
|
||||
});
|
||||
|
||||
async function testMissedResponses(sendShouldFail: boolean) {
|
||||
const logMessages = await testUtils.captureLog('debug', async () => {
|
||||
const {cliComm, forwarder} = await startManagedConnection({...assortedMethods,
|
||||
// An extra method that simulates a lost connection on server side prior to response.
|
||||
testDisconnect: async function(client, x, y) {
|
||||
await delay(0); // disconnect on the same tick.
|
||||
await forwarder.disconnectServerSide();
|
||||
if (!sendShouldFail) {
|
||||
// Add a delay to let the 'close' event get noticed first.
|
||||
await delay(20);
|
||||
}
|
||||
return {x: x, y: y, name: "testDisconnect"};
|
||||
},
|
||||
});
|
||||
let failedSendCount = 0;
|
||||
|
||||
const resp1 = await cliComm._makeRequest(null, null, "methodSync", "foo", 1);
|
||||
assert.deepEqual(resp1, {name: 'methodSync', x: "foo", y: 1});
|
||||
|
||||
// Make more calls, with a disconnect before they return. The server should queue up responses.
|
||||
const resp2Promise = cliComm._makeRequest(null, null, "testDisconnect", "foo", 2);
|
||||
const resp3Promise = cliComm._makeRequest(null, null, "methodAsync", "foo", 3);
|
||||
assert.equal(await isLongerThan(resp2Promise, 250), true);
|
||||
|
||||
// Once we reconnect, the response should arrive.
|
||||
await forwarder.connect();
|
||||
assert.deepEqual(await resp2Promise, {name: 'testDisconnect', x: "foo", y: 2});
|
||||
assert.deepEqual(await resp3Promise, {name: 'methodAsync', x: "foo", y: 3});
|
||||
const {cliComm, forwarder} = await startManagedConnection({...assortedMethods,
|
||||
// An extra method that simulates a lost connection on server side prior to response.
|
||||
testDisconnect: async function(client, x, y) {
|
||||
setTimeout(() => forwarder.disconnectServerSide(), 0);
|
||||
if (!sendShouldFail) {
|
||||
// Add a delay to let the 'close' event get noticed first.
|
||||
await delay(20);
|
||||
}
|
||||
return {x: x, y: y, name: "testDisconnect"};
|
||||
},
|
||||
});
|
||||
|
||||
// Check that we saw the situations we were hoping to test.
|
||||
assert.equal(logMessages.some(m => /^warn: .*send error.*WebSocket is not open/.test(m)), sendShouldFail,
|
||||
`Expected to see a failed send:\n${logMessages.join('\n')}`);
|
||||
const resp1 = await cliComm._makeRequest(null, null, "methodSync", "foo", 1);
|
||||
assert.deepEqual(resp1, {name: 'methodSync', x: "foo", y: 1});
|
||||
|
||||
if (sendShouldFail) {
|
||||
// In Node 18, the socket is closed during the call to 'testDisconnect'.
|
||||
// In prior versions of Node, the socket was still disconnecting.
|
||||
// This test is sensitive to timing and only passes in the latter, unless we
|
||||
// stub the method below to produce similar behavior in the former.
|
||||
sandbox.stub(Client.prototype as any, '_sendToWebsocket')
|
||||
.onFirstCall()
|
||||
.callsFake(() => {
|
||||
failedSendCount += 1;
|
||||
throw new Error('WebSocket is not open');
|
||||
})
|
||||
.callThrough();
|
||||
}
|
||||
|
||||
// Make more calls, with a disconnect before they return. The server should queue up responses.
|
||||
const resp2Promise = cliComm._makeRequest(null, null, "testDisconnect", "foo", 2);
|
||||
const resp3Promise = cliComm._makeRequest(null, null, "methodAsync", "foo", 3);
|
||||
assert.equal(await isLongerThan(resp2Promise, 250), true);
|
||||
|
||||
// Once we reconnect, the response should arrive.
|
||||
await forwarder.connect();
|
||||
assert.deepEqual(await resp2Promise, {name: 'testDisconnect', x: "foo", y: 2});
|
||||
assert.deepEqual(await resp3Promise, {name: 'methodAsync', x: "foo", y: 3});
|
||||
|
||||
// Check that we saw the situation we were hoping to test.
|
||||
assert.equal(failedSendCount, sendShouldFail ? 1 : 0, 'Expected to see a failed send');
|
||||
}
|
||||
|
||||
it("should receive all server messages (small) in order when send doesn't fail", async function() {
|
||||
|
||||
@@ -20,7 +20,7 @@ export function addStatic(app: express.Express, rootDir?: string) {
|
||||
res.sendFile(req.params[0], {root:
|
||||
path.resolve(getAppRoot(), "static")}));
|
||||
app.use(express.static(rootDir || path.resolve(fixturesRoot, "sites"), {
|
||||
setHeaders: (res) => {
|
||||
setHeaders: (res: express.Response) => {
|
||||
res.set("Access-Control-Allow-Origin", "*");
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -17,8 +17,8 @@ import {
|
||||
import {delayAbort} from 'app/server/lib/serverUtils';
|
||||
import axios, {AxiosRequestConfig, AxiosResponse} from 'axios';
|
||||
import {delay} from 'bluebird';
|
||||
import * as bodyParser from 'body-parser';
|
||||
import {assert} from 'chai';
|
||||
import * as express from 'express';
|
||||
import FormData from 'form-data';
|
||||
import * as fse from 'fs-extra';
|
||||
import * as _ from 'lodash';
|
||||
@@ -3786,7 +3786,7 @@ function testDocApi() {
|
||||
|
||||
// TODO test retries on failure and slowness in a new test
|
||||
serving = await serveSomething(app => {
|
||||
app.use(bodyParser.json());
|
||||
app.use(express.json());
|
||||
app.post('/200', ({body}, res) => {
|
||||
successCalled.emit(body[0].A);
|
||||
res.sendStatus(200);
|
||||
|
||||
@@ -8,12 +8,24 @@ import {assert} from 'chai';
|
||||
import * as sinon from 'sinon';
|
||||
import {TestServer} from 'test/gen-server/apiUtils';
|
||||
import {configForUser} from 'test/gen-server/testUtils';
|
||||
import * as testUtils from 'test/server/testUtils';
|
||||
|
||||
const chimpy = configForUser('Chimpy');
|
||||
const kiwi = configForUser('Kiwi');
|
||||
const anon = configForUser('Anonymous');
|
||||
|
||||
describe('Telemetry', function() {
|
||||
let oldEnv: testUtils.EnvironmentSnapshot;
|
||||
|
||||
before(async function() {
|
||||
oldEnv = new testUtils.EnvironmentSnapshot();
|
||||
process.env.TYPEORM_DATABASE = ':memory:';
|
||||
});
|
||||
|
||||
after(function() {
|
||||
oldEnv.restore();
|
||||
});
|
||||
|
||||
const variants: [GristDeploymentType, TelemetryLevel, PrefSource][] = [
|
||||
['saas', 'off', 'environment-variable'],
|
||||
['saas', 'limited', 'environment-variable'],
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {UserAPIImpl} from 'app/common/UserAPI';
|
||||
import {WebhookSubscription} from 'app/server/lib/DocApi';
|
||||
import axios from 'axios';
|
||||
import * as bodyParser from 'body-parser';
|
||||
import {assert} from 'chai';
|
||||
import * as express from 'express';
|
||||
import {tmpdir} from 'os';
|
||||
import * as path from 'path';
|
||||
import {createClient} from 'redis';
|
||||
@@ -218,7 +218,7 @@ describe('Webhooks-Proxy', function () {
|
||||
this.timeout(30000);
|
||||
serving = await serveSomething(app => {
|
||||
|
||||
app.use(bodyParser.json());
|
||||
app.use(express.json());
|
||||
app.post('/200', ({body}, res) => {
|
||||
successCalled.emit(body[0].A);
|
||||
res.sendStatus(200);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {serveSomething, Serving} from "test/server/customUtil";
|
||||
import * as bodyParser from "body-parser";
|
||||
import {Request, Response} from "express-serve-static-core";
|
||||
import * as express from "express";
|
||||
import axios from "axios";
|
||||
|
||||
export class TestProxyServer {
|
||||
@@ -27,8 +26,8 @@ export class TestProxyServer {
|
||||
|
||||
private async _prepare(portNumber: number) {
|
||||
this._proxyServing = await serveSomething(app => {
|
||||
app.use(bodyParser.json());
|
||||
app.all('*', async (req: Request, res: Response) => {
|
||||
app.use(express.json());
|
||||
app.all('*', async (req: express.Request, res: express.Response) => {
|
||||
this._proxyCallsCounter += 1;
|
||||
let responseCode;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user