@remnic/coding-graph 9.6.38 → 9.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +9 -0
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/lsp/resolution.test.ts +125 -0
- package/src/lsp/resolution.ts +35 -1
package/dist/index.d.ts
CHANGED
|
@@ -1183,6 +1183,15 @@ declare function planLspUpgrades(callSites: readonly UnresolvedCallSite[], budge
|
|
|
1183
1183
|
interface ResolveOptions {
|
|
1184
1184
|
readonly client: LspClient;
|
|
1185
1185
|
readonly nodeLocator: NodeLocator;
|
|
1186
|
+
/**
|
|
1187
|
+
* Warm-up retry delay in ms (issue #1933). Language servers (tsserver
|
|
1188
|
+
* in particular) load projects ASYNCHRONOUSLY after `didOpen`; a
|
|
1189
|
+
* definition request that arrives too early returns an EMPTY location
|
|
1190
|
+
* array — indistinguishable from "definitely no definition". Until the
|
|
1191
|
+
* server has proven warm (any non-empty response), an empty result is
|
|
1192
|
+
* retried ONCE after this delay. Default 2500. Set 0 to disable.
|
|
1193
|
+
*/
|
|
1194
|
+
readonly warmupRetryDelayMs?: number;
|
|
1186
1195
|
/**
|
|
1187
1196
|
* Apply a batch of edge upgrades atomically. Called once per file batch.
|
|
1188
1197
|
* MUST be transactional — if it throws, zero upgrades from this batch
|
package/dist/index.js
CHANGED
|
@@ -2944,6 +2944,8 @@ async function executeLspResolution(requests, options) {
|
|
|
2944
2944
|
let upgraded = 0;
|
|
2945
2945
|
let unresolved = 0;
|
|
2946
2946
|
let degradation;
|
|
2947
|
+
let serverWarm = false;
|
|
2948
|
+
const warmupRetryDelayMs = options.warmupRetryDelayMs ?? 2500;
|
|
2947
2949
|
for (const [filePath, batchReqs] of byFile) {
|
|
2948
2950
|
const upgrades = [];
|
|
2949
2951
|
let batchFailed = false;
|
|
@@ -2961,10 +2963,22 @@ async function executeLspResolution(requests, options) {
|
|
|
2961
2963
|
unresolved += batchReqs.length - i;
|
|
2962
2964
|
break;
|
|
2963
2965
|
}
|
|
2964
|
-
|
|
2966
|
+
let defResult = await client.definition({
|
|
2965
2967
|
textDocument: { uri: filePathToUri(req.filePath, options.workspaceRoot) },
|
|
2966
2968
|
position: req.position
|
|
2967
2969
|
});
|
|
2970
|
+
if (defResult.ok && defResult.locations.length === 0 && !serverWarm && warmupRetryDelayMs > 0) {
|
|
2971
|
+
await new Promise((resolve) => setTimeout(resolve, warmupRetryDelayMs));
|
|
2972
|
+
serverWarm = true;
|
|
2973
|
+
const retryResult = await client.definition({
|
|
2974
|
+
textDocument: { uri: filePathToUri(req.filePath, options.workspaceRoot) },
|
|
2975
|
+
position: req.position
|
|
2976
|
+
});
|
|
2977
|
+
defResult = retryResult;
|
|
2978
|
+
}
|
|
2979
|
+
if (defResult.ok && defResult.locations.length > 0) {
|
|
2980
|
+
serverWarm = true;
|
|
2981
|
+
}
|
|
2968
2982
|
if (!defResult.ok) {
|
|
2969
2983
|
if (defResult.degradation.code === "server_crashed" || defResult.degradation.code === "protocol_error") {
|
|
2970
2984
|
degradation = defResult.degradation;
|