Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions packages/language-core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,18 @@ export const DEPENDENCY_FILE_GLOB = `**/{${PACKAGE_JSON_BASENAME},${PNPM_WORKSPA

export const CACHE_MAX_AGE_ONE_DAY = 60 * 60 * 24

/**
* The maximum cache age (in seconds) accepted by `ocache`'s `maxAge` option.
*
* This is the largest whole number of seconds that can be expressed within a
* 32-bit signed integer (`(2 ** 31 - 1) / 1000 ≈ 596523` hours). It acts as a
* safe upper bound for caches that should effectively live forever.
*
* This was introduced to cope with a breaking change in `ocache`: the previous
* idiom of passing `-1` to disable expiration is no longer supported, so we
* pass the largest valid `maxAge` instead to keep entries from expiring.
*/
export const CACHE_MAX_AGE_MAXIMUM = Math.trunc((2 ** 31 - 1) / 1000)

export const NPMX_DEV = 'https://npmx.dev'
export const NPMX_DEV_API = `${NPMX_DEV}/api`
4 changes: 2 additions & 2 deletions packages/language-server/src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { Connection, LanguageServer } from '@volar/language-server'
import type { DependencyInfo, PackageManager, WorkspaceAdapter } from 'npmx-language-core/workspace'
import type { ClientFeatures, IWorkspaceState } from 'npmx-language-service/types'
import { access, realpath as fsRealpath, readFile } from 'node:fs/promises'
import { DEPENDENCY_FILE_GLOB, PACKAGE_JSON_BASENAME } from 'npmx-language-core/constants'
import { CACHE_MAX_AGE_MAXIMUM, DEPENDENCY_FILE_GLOB, PACKAGE_JSON_BASENAME } from 'npmx-language-core/constants'
import { isDependencyFile, isPackageManifest } from 'npmx-language-core/utils'
import { WorkspaceContext } from 'npmx-language-core/workspace'
import { DEFAULT_CLIENT_FEATURES } from 'npmx-language-service/types'
Expand Down Expand Up @@ -139,7 +139,7 @@ export class WorkspaceState implements IWorkspaceState {
{
name: 'workspace-context',
getKey: (folderUri) => folderUri.path,
maxAge: -1,
maxAge: CACHE_MAX_AGE_MAXIMUM,
swr: false,
staleMaxAge: 0,
},
Expand Down
Loading