-
Notifications
You must be signed in to change notification settings - Fork 976
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Maximum Call Stack Size Exceeded when using requireAuth with Func… (
- Loading branch information
Showing
3 changed files
with
46 additions
and
2 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
packages/graphql-server/src/functions/__tests__/globalContext.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { | ||
context as globalContext, | ||
getAsyncStoreInstance, | ||
setContext, | ||
} from '../../globalContext' | ||
|
||
describe('Global context with context isolation', () => { | ||
beforeAll(() => { | ||
process.env.DISABLE_CONTEXT_ISOLATION = '0' | ||
}) | ||
|
||
it('Should work when assigning directly into context', async () => { | ||
const asyncStore = getAsyncStoreInstance() | ||
|
||
asyncStore.run(new Map(), () => { | ||
// This is the actual test | ||
globalContext.myNewValue = 'bazinga' | ||
|
||
expect(globalContext.myNewValue).toBe('bazinga') | ||
}) | ||
|
||
// Check that context was isolated | ||
expect(globalContext.myNewValue).not.toBe('bazinga') | ||
}) | ||
|
||
it('Should work when using setContext', async () => { | ||
const asyncStore = getAsyncStoreInstance() | ||
|
||
asyncStore.run(new Map(), () => { | ||
// This is the actual test | ||
setContext({ anotherValue: 'kittens' }) | ||
|
||
expect(globalContext.anotherValue).toBe('kittens') | ||
}) | ||
|
||
// Check that context was isolated | ||
expect(globalContext.anotherValue).not.toBe('kittens') | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters