Skip to content

Commit

Permalink
rename ALS
Browse files Browse the repository at this point in the history
  • Loading branch information
lubieowoce committed Dec 2, 2024
1 parent efa53a5 commit 8fb2bbc
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 24 deletions.
4 changes: 2 additions & 2 deletions packages/next/src/server/after/after-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
workUnitAsyncStorage,
type WorkUnitStore,
} from '../app-render/work-unit-async-storage.external'
import { workUnitSnapshotAsyncStorage } from '../app-render/work-unit-snapshot-async-storage.external'
import { afterTaskAsyncStorage } from '../app-render/after-task-async-storage.external'

export type AfterContextOpts = {
isEnabled: boolean
Expand Down Expand Up @@ -89,7 +89,7 @@ export class AfterContext {
if (!originalPhase) {
await callback()
} else {
await workUnitSnapshotAsyncStorage.run({ phase: originalPhase }, () =>
await afterTaskAsyncStorage.run({ phase: originalPhase }, () =>
callback()
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { AfterTaskAsyncStorage } from './after-task-async-storage.external'
import { createAsyncLocalStorage } from './async-local-storage'

export const _afterTaskAsyncStorage: AfterTaskAsyncStorage =
createAsyncLocalStorage()
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { AsyncLocalStorage } from 'async_hooks'

// Share the instance module in the next-shared layer
import { _afterTaskAsyncStorage as afterTaskAsyncStorage } from './after-task-async-storage-instance' with { 'turbopack-transition': 'next-shared' }
import type { WorkUnitStore } from './work-unit-async-storage.external'

export interface AfterTaskStore {
readonly phase: WorkUnitStore['phase']
}

export type AfterTaskAsyncStorage = AsyncLocalStorage<AfterTaskStore>

export { afterTaskAsyncStorage }

This file was deleted.

This file was deleted.

6 changes: 3 additions & 3 deletions packages/next/src/server/request/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { StaticGenBailoutError } from '../../client/components/static-generation-bailout'
import { workUnitSnapshotAsyncStorage } from '../app-render/work-unit-snapshot-async-storage.external'
import { afterTaskAsyncStorage } from '../app-render/after-task-async-storage.external'

// This regex will have fast negatives meaning valid identifiers may not pass
// this test. However this is only used during static generation to provide hints
Expand Down Expand Up @@ -44,10 +44,10 @@ export function throwWithStaticGenerationBailoutErrorWithDynamicError(
export function isRequestAPICallableInsideAfter() {
// const workStore = workAsyncStorage.getStore()
// const workUnitStore = workUnitAsyncStorage.getStore()
const workUnitSnapshotStore = workUnitSnapshotAsyncStorage.getStore()
const afterTaskStore = afterTaskAsyncStorage.getStore()
return (
// workUnitStore?.type === 'request' &&
workUnitSnapshotStore?.phase === 'action'
afterTaskStore?.phase === 'action'
)
}

Expand Down

0 comments on commit 8fb2bbc

Please sign in to comment.