Repository: blitz-js/superjson (ts)

Issue:
Serialized errors should not include `stack` by default
Currently stack is preserved for errors: https://github.com/blitz-js/superjson/blob/16cae250549e4822a22a014bb96597468dfff33f/src/transformer.ts#L110

Pull request description:
Fix #108
Closes #108 

Patch:
diff --git a/src/transformer.ts b/src/transformer.ts
index aee8956..f195acc 100644
--- a/src/transformer.ts
+++ b/src/transformer.ts
@@ -107,7 +107,6 @@ const simpleRules = [
       const baseError: any = {
         name: v.name,
         message: v.message,
-        stack: v.stack,
       };
 
       allowedErrorProps.forEach(prop => {


Test patch:
diff --git a/src/index.test.ts b/src/index.test.ts
index 0a33c9c..18368a0 100644
--- a/src/index.test.ts
+++ b/src/index.test.ts
@@ -188,9 +188,6 @@ describe('stringify & parse', () => {
       output: ({ e }: any) => {
         expect(e.name).toBe('Error');
         expect(e.message).toBe('epic fail');
-        expect(e.stack.startsWith('Error: epic fail\n    at Suite.')).toBe(
-          true
-        );
       },
       outputAnnotations: {
         values: {
@@ -843,3 +840,19 @@ test('regression #95: no undefined', () => {
 
   expect(parsed).toEqual(input);
 });
+
+test('regression #108: Error#stack should not be included by default', () => {
+  const input = new Error("Beep boop, you don't wanna see me. I'm an error!");
+  expect(input).toHaveProperty('stack');
+
+  const { stack: thatShouldBeUndefined } = SuperJSON.parse(
+    SuperJSON.stringify(input)
+  ) as any;
+  expect(thatShouldBeUndefined).toBeUndefined();
+
+  SuperJSON.allowErrorProps('stack');
+  const { stack: thatShouldExist } = SuperJSON.parse(
+    SuperJSON.stringify(input)
+  ) as any;
+  expect(thatShouldExist).toEqual(input.stack);
+});