memory: file-lock test "stops refreshing a lock that was broken and re-taken" races its own heartbeat on a slow runner

Aberta Para iniciantes
#5,634 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
76/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
typescript
Domínio
testing

Direção de pesquisa

Comece por src/memory/__tests__/file-lock.test.ts, no teste de withFileLock chamado “stops refreshing a lock that was broken and re-taken while it ran.” Leia como o utimes simulado, o spy de readFile e os temporizadores reais se coordenam; em seguida, torne a asserção independente do agendamento do runner. Execute o teste específico com verify:no-test-retries; ele estará concluído quando passar de forma confiável, sem novas tentativas, em CI lento.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

chore server-memory v2

Problem

src/memory/__tests__/file-lock.test.ts > withFileLock > stops refreshing a lock that was broken and re-taken while it ran (#5418) failed on CI with AssertionError: expected 0 to be greater than 0 (Coverage memory, run 44417378815, job 135201148642, on PR #5628's caught-up head). That PR changes only src/git/; the test is unchanged on v2/main, including after #5623.

Cause

The test runs on real timers (staleMs: 200, so a heartbeat every 100 ms). The first heartbeat's utimes is mocked to replace the lock with another owner's and then resolve replacement. The operation then clears the readFile spy and expects, within a 250 ms sleep, at least one read of the lock: the next heartbeat seeing the new token and stopping.

On a loaded runner (the coverage leg is instrumented), the next heartbeat can read the lock before the operation resumes and clears the spy. That read is wiped, the heartbeat stops as intended, and no further read follows, so the count is 0. The behavior under test is correct; the assertion depends on scheduling.

Expected

The test passes regardless of runner speed, with no retry (verify:no-test-retries). For example: drive the heartbeat with fake timers, or count reads from the moment the replacement is made (inside the mocked utimes) instead of clearing after the operation resumes.

Linguagem predominante
TypeScript
Estrelas
92k
Forks
12k
Merge médio
3h 46min
PRs com merge (30d)
206

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de modelcontextprotocol/servers

Todas as issues de modelcontextprotocol/servers

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.