test(api/server_requests_spec): fix flaky test (again) (#36570)

Use a fast API, as a deferred API request may be aborted by EOF.
This commit is contained in:
zeertzjq
2025-11-16 17:47:16 +08:00
committed by GitHub
parent 39e27d64ad
commit c924d68021
2 changed files with 6 additions and 8 deletions

View File

@@ -77,7 +77,7 @@ describe('notify', function()
end)
end)
it('cancels stale events on channel close', function()
it('cancels stale events on channel close #13537', function()
local catchan = eval("jobstart(['cat'], {'rpc': v:true})")
local catpath = eval('exepath("cat")')
eq(

View File

@@ -297,7 +297,7 @@ describe('server -> client', function()
eq(serverpid, fn.getpid())
eq('hello', api.nvim_get_current_line())
-- method calls work both ways
-- Method calls work both ways.
fn.rpcrequest(client_id, 'nvim_set_current_line', 'howdy!')
eq(id, fn.rpcrequest(client_id, 'nvim_get_chan_info', 0).id)
@@ -305,18 +305,16 @@ describe('server -> client', function()
eq(clientpid, fn.getpid())
eq('howdy!', api.nvim_get_current_line())
-- sending notification and then closing channel immediately still works
-- Sending notification and then closing channel immediately still works.
-- Use a fast API here, as a deferred API call may be aborted by EOF. #13537
n.exec_lua(function()
vim.rpcnotify(id, 'nvim_set_current_line', 'bye!')
vim.rpcnotify(id, 'nvim_input', 'ccbye!<Esc>')
vim.fn.chanclose(id)
end)
set_session(server)
eq(serverpid, fn.getpid())
-- wait for the notification to be processed
t.retry(nil, 1000, function()
eq('bye!', api.nvim_get_current_line())
end)
eq('bye!', api.nvim_get_current_line())
server:close()
client:close()