Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: task git.status does a sync call in it's on_exit #1569

Closed
3 tasks done
CWood-sdf opened this issue Jun 27, 2024 · 14 comments
Closed
3 tasks done

bug: task git.status does a sync call in it's on_exit #1569

CWood-sdf opened this issue Jun 27, 2024 · 14 comments
Labels
bug Something isn't working

Comments

@CWood-sdf
Copy link

Did you check docs and existing issues?

  • I have read all the lazy.nvim docs
  • I have searched the existing issues of lazy.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

nightly, pulled 1 hr ago

Operating system/version

arch

Describe the bug

In commit 0614ca6, a bug exists somewhere that causes an infinite loop in something. I don't have many details on it because I am about to fall asleep and it is very late, I am posting the issue now just to get it on your radar so you could do some preliminary checks for something.

Steps To Reproduce

I'll do this tomorrow

Expected Behavior

not to have an infinite loop

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@CWood-sdf CWood-sdf added the bug Something isn't working label Jun 27, 2024
@CWood-sdf CWood-sdf changed the title bug: Infinite loop in 0614ca6ca629704cb1846c0d6f9a250b526900b9 bug: Infinite loop in 0614ca6 Jun 27, 2024
@max397574
Copy link
Contributor

is it reproducible with the minimal template you sent?

Idea: rockspec has a dependency which has the plugin itself as dependency again

@folke
Copy link
Owner

folke commented Jun 27, 2024

@max397574 that shouldn't cause issue

@folke
Copy link
Owner

folke commented Jun 27, 2024

I fixed some things related to running tasks, that may have fixed the issue you experienced.
When you have the time, can you:

  • Update lazy to the latest HEAD
  • Show any errors you get in Neovim
  • Show :checkhealth lazy
  • Ideally provide a repro.lua or a link to your neovim dots

@folke

This comment was marked as outdated.

@folke
Copy link
Owner

folke commented Jun 27, 2024

I'm debugging your profile. Will add some remarks.

  • You need to add M.remaps[currentGroupMode] = M.remaps[currentGroupMode] or {} to line 19 in wkutils.lua

@folke
Copy link
Owner

folke commented Jun 27, 2024

looking into:
image

@folke
Copy link
Owner

folke commented Jun 27, 2024

Found the issue (not lazy.nvim's fault):

  • when you have no plugins installed
  • then when loading the spec for conform.nvim, you're loading stuff.config
  • in stuff.config you do require("cmdTree")
  • since you're still installing plugins, that module does not yet exist, so it will fail to install conform

It's never a good idea to import modules top-level in specs. Always use closures...

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Jun 27, 2024
@CWood-sdf
Copy link
Author

I was able to replicate the bug with a repro.lua:

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
    vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
    "folke/tokyonight.nvim",
    "stevearc/conform.nvim",
    --"nvim-treesitter/nvim-treesitter",
    --{ "nvim-neotest/neotest-plenary" },
    {
        "nvim-neotest/neotest",
        opts = {
            adapters = {
                ["neotest-plenary"] = {
                    min_init = "./tests/init.lua",
                },
            }
        },
    },

    "nvim-neotest/nvim-nio",
    -- add any other plugins here
}
require("lazy").setup(plugins, {
    root = root .. "/plugins",
    change_detection = {
        notify = false,
    },
    -- install = {
    -- 	-- missing = false,
    -- },
    checker = {
        enabled = true,
        frequency = 300,
        notify = false,
    },

})

vim.cmd.colorscheme("tokyonight")

vim.defer_fn(function()
	require("lazy.manage.checker").check()
	if require("lazy.status").has_updates() then
	print(require('lazy.status').updates())
	end
	require("lazy.manage.checker").check()
	if require("lazy.status").has_updates() then
	print(require('lazy.status').updates())
	end
	require("lazy.manage.checker").check()
	if require("lazy.status").has_updates() then
	print(require('lazy.status').updates())
	end
	
end, 100)

I think it is the same problem as #1568, the git-remote-https program gets hung, but it seems that somewhere along the .check() function stack, there is a synchronous function that forces the function to wait for the git-remote-https process to end (which takes a while). This problem also occurs with the opts.checker auto checker for status lines (which causes neovim to randomly freeze up for about two minutes every five minutes (because my checker frequency is 300s).

@folke
Copy link
Owner

folke commented Jun 27, 2024

What is this repro supposed to show? It doesn't do anything special for me...

@CWood-sdf
Copy link
Author

CWood-sdf commented Jun 27, 2024

For me the git-remote-https process hangs about 80% of the time that neovim is opened with the repro. Somewhere in the .check() is synchronous (at least that's the best explanation I have), so it causes neovim to completely freeze up, using 100% of a single core for the 2 minutes that git-remote-https is sitting.

folke added a commit that referenced this issue Jun 27, 2024
@folke
Copy link
Owner

folke commented Jun 27, 2024

The only part that could cause this is if you have a plugin dir with a git dirty doc/tags file.
I just pushed a temp fix for that. Will make a proper fix tomorrow.
Can you confirm that with the latest lazy.nvim HEAD you no longer see the hanging?
Something weird with cursor flickering might still happen for now.

@folke folke reopened this Jun 27, 2024
@folke folke changed the title bug: Infinite loop in 0614ca6 bug: task git.status does a sync call in it's on_exit Jun 27, 2024
@CWood-sdf
Copy link
Author

unfortunately that did not fix the problem. there's still 100% usage on one cpu core

@folke
Copy link
Owner

folke commented Jun 28, 2024

Did you open the repro and ran :Lazy update inside to update lazy?
I didn't make a new release yet, so if you didn't update or if you'd just delete the .repro directory, it would have used the old version

@folke
Copy link
Owner

folke commented Jun 28, 2024

Closing, since with the latest changes I just released it should no longer happen, even on slower machines.
Do let me know if the issue would not be resolved

@folke folke closed this as completed Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants