Skip to content

chore: lazy-load server plugin modules (security-solution)#266619

Merged
afharo merged 3 commits intomainfrom
chore/lazy-plugin-import-security-solution
May 5, 2026
Merged

chore: lazy-load server plugin modules (security-solution)#266619
afharo merged 3 commits intomainfrom
chore/lazy-plugin-import-security-solution

Conversation

@afharo
Copy link
Copy Markdown
Member

@afharo afharo commented Apr 30, 2026

Summary

Lazy-load server plugin implementations via await import('./plugin') (and related entrypoint adjustments) from server/index.ts, consistent with #170856.

The migration in #170856 reduced startup time by ~4 seconds in measured scenarios. Memory savings were not quantified but are expected.

CODEOWNERS

  • indices_metadata → @elastic/security-solution

Follow-up


Disclaimer: This PR was prepared with AI assistance (Cursor / Claude); please review thoroughly.

@afharo afharo added backport:version Backport to applied version labels v9.4.0 release_note:skip Skip the PR/issue when compiling release notes labels Apr 30, 2026
@afharo afharo marked this pull request as ready for review April 30, 2026 11:20
@afharo afharo requested a review from a team as a code owner April 30, 2026 11:20
@afharo afharo enabled auto-merge (squash) April 30, 2026 11:20
@afharo afharo added the Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. label Apr 30, 2026
@afharo
Copy link
Copy Markdown
Member Author

afharo commented May 2, 2026

@elasticmachine merge upstream

@kibanamachine
Copy link
Copy Markdown
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #207 / Agent Builder agents Edit agent should edit agent name

Metrics [docs]

✅ unchanged

History

@afharo afharo merged commit 0834546 into main May 5, 2026
26 checks passed
@afharo afharo deleted the chore/lazy-plugin-import-security-solution branch May 5, 2026 11:12
@szaffarano
Copy link
Copy Markdown
Contributor

Thanks!

@kibanamachine
Copy link
Copy Markdown
Contributor

Starting backport for target branches: 9.4

https://github.com/elastic/kibana/actions/runs/25372993721

@kibanamachine
Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
9.4

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request May 5, 2026
…6619) (#267701)

# Backport

This will backport the following commits from `main` to `9.4`:
- [chore: lazy-load server plugin modules (security-solution)
(#266619)](#266619)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Alejandro Fernández
Haro","email":"alejandro.haro@elastic.co"},"sourceCommit":{"committedDate":"2026-05-05T11:12:50Z","message":"chore:
lazy-load server plugin modules (security-solution) (#266619)\n\n##
Summary\n\nLazy-load server plugin implementations via `await
import('./plugin')`\n(and related entrypoint adjustments) from
`server/index.ts`, consistent\nwith
https://github.com/elastic/kibana/pull/170856.\n\nThe migration in
#170856 reduced **startup time by ~4 seconds** in\nmeasured scenarios.
**Memory savings were not quantified but are\nexpected.**\n\n##
CODEOWNERS\n\n- `indices_metadata` → @elastic/security-solution\n\n##
Follow-up\n\n- #171080 — add an
ESLint rule\nso new plugins follow this
pattern.\n\n---\n\n**Disclaimer:** This PR was prepared with AI
assistance (Cursor /\nClaude); please review
thoroughly.","sha":"08345467a0ba73065b1722c4badba63a5f6022d0","branchLabelMapping":{"^v9.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:
SecuritySolution","backport:version","v9.4.0","v9.5.0"],"title":"chore:
lazy-load server plugin modules
(security-solution)","number":266619,"url":"https://github.com/elastic/kibana/pull/266619","mergeCommit":{"message":"chore:
lazy-load server plugin modules (security-solution) (#266619)\n\n##
Summary\n\nLazy-load server plugin implementations via `await
import('./plugin')`\n(and related entrypoint adjustments) from
`server/index.ts`, consistent\nwith
https://github.com/elastic/kibana/pull/170856.\n\nThe migration in
#170856 reduced **startup time by ~4 seconds** in\nmeasured scenarios.
**Memory savings were not quantified but are\nexpected.**\n\n##
CODEOWNERS\n\n- `indices_metadata` → @elastic/security-solution\n\n##
Follow-up\n\n- #171080 — add an
ESLint rule\nso new plugins follow this
pattern.\n\n---\n\n**Disclaimer:** This PR was prepared with AI
assistance (Cursor /\nClaude); please review
thoroughly.","sha":"08345467a0ba73065b1722c4badba63a5f6022d0"}},"sourceBranch":"main","suggestedTargetBranches":["9.4"],"targetPullRequestStates":[{"branch":"9.4","label":"v9.4.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.5.0","branchLabelMappingKey":"^v9.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/266619","number":266619,"mergeCommit":{"message":"chore:
lazy-load server plugin modules (security-solution) (#266619)\n\n##
Summary\n\nLazy-load server plugin implementations via `await
import('./plugin')`\n(and related entrypoint adjustments) from
`server/index.ts`, consistent\nwith
https://github.com/elastic/kibana/pull/170856.\n\nThe migration in
#170856 reduced **startup time by ~4 seconds** in\nmeasured scenarios.
**Memory savings were not quantified but are\nexpected.**\n\n##
CODEOWNERS\n\n- `indices_metadata` → @elastic/security-solution\n\n##
Follow-up\n\n- #171080 — add an
ESLint rule\nso new plugins follow this
pattern.\n\n---\n\n**Disclaimer:** This PR was prepared with AI
assistance (Cursor /\nClaude); please review
thoroughly.","sha":"08345467a0ba73065b1722c4badba63a5f6022d0"}}]}]
BACKPORT-->

Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>
afharo added a commit that referenced this pull request May 5, 2026
…266636)

⚠️ CI is failing until all plugins are migrated (2 tiny PRs pending to
be approved).

- [x] #266620
- [x] #266619

## Summary

Implements the ESLint rule requested in #171080 to support the plugin
server entry pattern from #170856: `server/index.ts` should not
synchronously load `./plugin` (value imports, re-exports, side-effect
`import './plugin'`, or `require('./plugin')`); `import type` / `export
type` and dynamic `import()` are allowed.

- New rule: `@kbn/eslint/no_sync_import_from_plugin` in
`@kbn/eslint-plugin-eslint` with Jest tests.
- `@kbn/eslint-config` override for plugin `server/index.ts` paths: rule
is `error` so CI enforces the pattern; the number of violations should
decrease as lazy-load `server/index.ts` migrations land.
- `AGENTS.md`: document the pattern and the rule.

**Closes** #171080

## Review disclaimer

This PR was drafted with AI assistance (Cursor / Composer). Please give
it a thorough review—especially rule edge cases and interaction with
in-flight migration PRs.

Made with [Cursor](https://cursor.com)

---------

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:skip Skip the PR/issue when compiling release notes Team: SecuritySolution Security Solutions Team working on SIEM, Endpoint, Timeline, Resolver, etc. v9.4.0 v9.5.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants