Skip to content

Named import bug #258

@jimafisk

Description

@jimafisk

There seems to be a bug when doing certain types of imports: Error: runtime error: index out of range [-1]

Full error
Please create a valid Plenti project or fix your app structure before trying to run this command again.
Error: runtime error: index out of range [-1] 

goroutine 22 [running]:
runtime/debug.Stack()
        /usr/local/go/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
        /usr/local/go/src/runtime/debug/stack.go:16 +0x19
github.com/plentico/plenti/cmd.Build.func1()
        /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build.go:70 +0xdd
panic({0x18af240, 0xc00040c450})
        /usr/local/go/src/runtime/panic.go:838 +0x207
github.com/plentico/plenti/cmd/build.compileSvelte(0x673?, 0x18e53ff?, {0xc0004b8060, 0x24}, {0xc0002ec000, 0x673}, {0xc0004b80f0, 0x2b}, {0xc00040c210, 0x15})
        /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build/compile.go:159 +0x19db
github.com/plentico/plenti/cmd/build.compileComponent({0x0?, 0x0?}, {0xc0004b8060, 0x24}, {0x200000003?, 0xc000589040?}, {0xc0004ca080?, 0xc00012b4b8?}, 0x84ee4a?, 0xc00000e108, ...)
        /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build/client.go:247 +0x485
github.com/plentico/plenti/cmd/build.Client.func3({0xc0004b8060, 0x24}, {0x2034c10, 0xc0003fc1a0}, {0x100?, 0xffffffffffffff9c?})
        /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build/client.go:182 +0x165
path/filepath.walk({0xc0004b8060, 0x24}, {0x2034c10, 0xc0003fc1a0}, 0xc00012b970)
        /usr/local/go/src/path/filepath/path.go:418 +0x123
path/filepath.walk({0xc00040c0d8, 0x15}, {0x2034c10, 0xc00019d1e0}, 0xc00012b970)
        /usr/local/go/src/path/filepath/path.go:442 +0x285
path/filepath.walk({0xc00046c3d0, 0xf}, {0x2034c10, 0xc0003fc340}, 0xc00012b970)
        /usr/local/go/src/path/filepath/path.go:442 +0x285
path/filepath.walk({0x18e6c2e, 0x7}, {0x2034c10, 0xc0003fc270}, 0xc00012b970)
        /usr/local/go/src/path/filepath/path.go:442 +0x285
path/filepath.Walk({0x18e6c2e, 0x7}, 0xc00012b970)
        /usr/local/go/src/path/filepath/path.go:505 +0x6c
github.com/plentico/plenti/cmd/build.Client({0xc0004ca080, 0x6}, {0x0?})
        /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build/client.go:174 +0x905
github.com/plentico/plenti/cmd.Build()
        /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/build.go:145 +0x979
github.com/plentico/plenti/cmd/serve.(*watcher).watch.func1()
        /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/serve/watcher.go:105 +0x1f3
created by github.com/plentico/plenti/cmd/serve.(*watcher).watch
        /home/jimafisk/Projects/jantcu/plentico/plenti/cmd/serve/watcher.go:86 +0x48c

@hlanderdev and I are still trying to pinpoint exactly what is causing this. One theory is that if you use the same named import (stores seem ok still) in both a child and parent component, you hit this error.

Notes:

  • The "out of index" seems to be thrown on
    layoutRootPath = strings.TrimSuffix(layoutRootPath, layoutParts[len(layoutParts)-2]+"/")
  • reStaticImport.FindAllString(ssrStr, -1) might be capturing too much

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions