Skip to content

Commit

Permalink
Fix crash when function result type contains a constructor property (#…
Browse files Browse the repository at this point in the history
…2941)

Signed-off-by: Jan Potoms <2109932+Janpot@users.noreply.github.com>
  • Loading branch information
Janpot authored Nov 28, 2023
1 parent 7099b94 commit 0f7795f
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/toolpad-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
"recharts": "2.10.1",
"semver": "7.5.4",
"serialize-javascript": "6.0.1",
"superjson": "2.2.1",
"superjson": "2.0.0",
"typescript": "5.3.2",
"vite": "5.0.2",
"vm-browserify": "1.1.2",
Expand Down
4 changes: 2 additions & 2 deletions packages/toolpad-app/src/rpcClient.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { parse as superjsonParse } from 'superjson';
import * as superjson from 'superjson';
import invariant from 'invariant';
import {
QueryClient,
Expand Down Expand Up @@ -41,7 +41,7 @@ function createRpcClient<D extends MethodResolvers>(endpoint: string | URL): Met
}
throw toolpadError;
}
return superjsonParse(response.result);
return superjson.parse(response.result);
}

throw new Error(`HTTP ${res.status}`);
Expand Down
2 changes: 1 addition & 1 deletion packages/toolpad-app/src/server/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { IncomingMessage, ServerResponse } from 'http';
import superjson from 'superjson';
import * as superjson from 'superjson';
import express from 'express';
import * as z from 'zod';
import { fromZodError } from 'zod-validation-error';
Expand Down
5 changes: 5 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
"allowedVersions": "<= 13.4.19",
"description": "https://github.com/mui/mui-toolpad/pull/2739"
},
{
"groupName": "superjson",
"matchPackageNames": ["superjson"],
"description": "they added a feature that breaks our app: https://github.com/blitz-js/superjson/pull/267. See https://github.com/blitz-js/superjson/issues/279"
},
{
"matchDepTypes": ["action"],
"pinDigests": true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,15 @@ export async function someNonJson() {
regexp: /foo/i,
};
}

export interface RowDataPacket {
constructor: {
name: 'RowDataPacket';
};
[column: string]: any;
[column: number]: any;
}

export async function mysqlResult(): Promise<RowDataPacket[]> {
return [];
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11759,10 +11759,10 @@ sucrase@^3.20.3, sucrase@^3.21.0:
pirates "^4.0.1"
ts-interface-checker "^0.1.9"

superjson@2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/superjson/-/superjson-2.2.1.tgz#9377a7fa80fedb10c851c9dbffd942d4bcf79733"
integrity sha512-8iGv75BYOa0xRJHK5vRLEjE2H/i4lulTjzpUXic3Eg8akftYjkmQDa8JARQ42rlczXyFR3IeRoeFCc7RxHsYZA==
superjson@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/superjson/-/superjson-2.0.0.tgz#7abcbe6c1badc2e689ea62c375ca257666a68282"
integrity sha512-W3n+NJ7TFjaLle8ihIIvsr/bbuKpnxeatsyjmhy7iSkom+/cshaHziCQAWXrHGWJVQSQFDOuES6C3nSEvcbrQg==
dependencies:
copy-anything "^3.0.2"

Expand Down

0 comments on commit 0f7795f

Please sign in to comment.