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] UMD method introduces universal. Error: [redi]: Injector cannot be accessed after it was disposed. #2351

Closed
2 tasks done
KingLiLi opened this issue May 30, 2024 · 1 comment · Fixed by #2515
Closed
2 tasks done
Assignees
Labels
bug Something isn't working

Comments

@KingLiLi
Copy link

KingLiLi commented May 30, 2024

在您提交此问题之前,您是否检查了以下内容?

  • 这真的是个问题吗?
  • 我已经在 Github Issues 中搜索过了,但没有找到类似的问题。

受影响的包和版本

最新的包

复现链接

复现例子:点销毁执行univer实例的,dispose就会报错,复现代码放到下面。

这是在线的复现demo:
码上掘金在线demo

完整的html代码会被格式化掉。所以分开放。

html head标签引入引入cdn:
`

<script src="https://unpkg.com/@univerjs/umd/lib/univer.full.umd.js"></script>
<script src="https://unpkg.com/@univerjs/umd/lib/locale/zh-CN.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@univerjs/umd/lib/univer.css">

`

html body标签:
<button id="destroy">销毁</button> <button id="load">加载</button>

脚本代码:
`

<script> var { UniverCore, UniverDesign, UniverDocs, UniverDocsUi, UniverEngineRender, UniverSheetsFormula, UniverUi, UniverSheets, UniverSheetsUi, UniverSheetsNumfmt, UniverEngineFormula, } = window var univer = new UniverCore.Univer({ theme: UniverDesign.defaultTheme, }); univer.registerPlugin(UniverEngineRender.UniverRenderEnginePlugin); univer.registerPlugin(UniverEngineFormula.UniverFormulaEnginePlugin); univer.registerPlugin(UniverUi.UniverUIPlugin, { container: "app", }); univer.registerPlugin(UniverDocs.UniverDocsPlugin, { hasScroll: false, }); univer.registerPlugin(UniverDocsUi.UniverDocsUIPlugin); univer.registerPlugin(UniverSheets.UniverSheetsPlugin); univer.registerPlugin(UniverSheetsUi.UniverSheetsUIPlugin); univer.registerPlugin(UniverSheetsNumfmt.UniverSheetsNumfmtPlugin); univer.registerPlugin(UniverSheetsFormula.UniverSheetsFormulaPlugin); univer.createUnit(UniverCore.UniverInstanceType.UNIVER_SHEET, {}) var univerAPI = UniverFacade.FUniver.newAPI(univer) // Functionality for the "销毁" button document.getElementById('destroy').addEventListener('click', function() { // 手动清理 Univer 实例 univer.dispose(); }); // Function to reload the Univer instance function reloadUniver() { univer = new UniverCore.Univer({ theme: UniverDesign.defaultTheme, }); univer.registerPlugin(UniverEngineRender.UniverRenderEnginePlugin); univer.registerPlugin(UniverEngineFormula.UniverFormulaEnginePlugin); univer.registerPlugin(UniverUi.UniverUIPlugin, { container: "app", }); univer.registerPlugin(UniverDocs.UniverDocsPlugin, { hasScroll: false, }); univer.registerPlugin(UniverDocsUi.UniverDocsUIPlugin); univer.registerPlugin(UniverSheets.UniverSheetsPlugin); univer.registerPlugin(UniverSheetsUi.UniverSheetsUIPlugin); univer.registerPlugin(UniverSheetsNumfmt.UniverSheetsNumfmtPlugin); univer.registerPlugin(UniverSheetsFormula.UniverSheetsFormulaPlugin); univer.createUnit(UniverCore.UniverInstanceType.UNIVER_SHEET, {}); } // Functionality for the "加载" button document.getElementById('load').addEventListener('click', function() { reloadUniver(); // Reload the Univer instance }); </script>

`

预期行为

应该正确销毁,不要报错才对

实际行为

实际销毁执行dispose就报错

Error: [redi]: Injector cannot be accessed after it was disposed

运行环境

Chrome

系统信息

No response

@KingLiLi KingLiLi added the bug Something isn't working label May 30, 2024
@univer-bot univer-bot bot changed the title [Bug] UMD方式引入univer。执行dispose后报错 Error: [redi]: Injector cannot be accessed after it was disposed [Bug] UMD method introduces universal. Error: [redi]: Injector cannot be accessed after it was disposed. May 30, 2024
@univer-bot
Copy link

univer-bot bot commented May 30, 2024

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿

Origin Title: [Bug] UMD方式引入univer。执行dispose后报错 Error: [redi]: Injector cannot be accessed after it was disposed

Title: [Bug] UMD method introduces universal. Error: [redi]: Injector cannot be accessed after it was disposed.


Before you submitted this question, did you check the following?

  • Is this really a problem?
  • I've searched Github Issues but haven't found any similar issues.

Affected packages and versions

latest package

Recurrence link

Reproduction example: If you click destroy to execute the univer instance, dispose will report an error. The reproduction code is below.

This is an online reproduction demo:
Code on Nuggets online demo

The complete html code will be formatted. So keep it separate.

Import the html head tag into cdn:
`

<script src="https://unpkg.com/@univerjs/umd/lib/univer.full.umd.js"></script>
<script src="https://unpkg.com/@univerjs/umd/lib/locale/zh-CN.js"></script>
<link rel="stylesheet" href="https://unpkg.com/@univerjs/umd/lib/univer.css">

`

html body tag:
<button id="destroy">Destroy</button> <button id="load">Load</button>

Script code:
`

<script> var { UniverCore, UniverDesign, UniverDocs, UniverDocsUi, UniverEngineRender, UniverSheetsFormula, UniverUi, UniverSheets, UniverSheetsUi, UniverSheetsNumfmt, UniverEngineFormula, } = window var univer = new UniverCore.Univer({ theme: UniverDesign.defaultTheme, }); univer.registerPlugin(UniverEngineRender.UniverRenderEnginePlugin); univer.registerPlugin(UniverEngineFormula.UniverFormulaEnginePlugin); univer.registerPlugin(UniverUi.UniverUIPlugin, { container: "app", }); univer.registerPlugin(UniverDocs.UniverDocsPlugin, { hasScroll: false, }); univer.registerPlugin(UniverDocsUi.UniverDocsUIPlugin); univer.registerPlugin(UniverSheets.UniverSheetsPlugin); univer.registerPlugin(UniverSheetsUi.UniverSheetsUIPlugin); univer.registerPlugin(UniverSheetsNumfmt.UniverSheetsNumfmtPlugin); univer.registerPlugin(UniverSheetsFormula.UniverSheetsFormulaPlugin); univer.createUnit(UniverCore.UniverInstanceType.UNIVER_SHEET, {}) var univerAPI = UniverFacade.FUniver.newAPI(univer) // Functionality for the "destroy" button document.getElementById('destroy').addEventListener('click', function() { // Manually clean up the Univer instance univer.dispose(); }); // Function to reload the Univer instance function reloadUniver() { univer = new UniverCore.Univer({ theme: UniverDesign.defaultTheme, }); univer.registerPlugin(UniverEngineRender.UniverRenderEnginePlugin); univer.registerPlugin(UniverEngineFormula.UniverFormulaEnginePlugin); univer.registerPlugin(UniverUi.UniverUIPlugin, { container: "app", }); univer.registerPlugin(UniverDocs.UniverDocsPlugin, { hasScroll: false, }); univer.registerPlugin(UniverDocsUi.UniverDocsUIPlugin); univer.registerPlugin(UniverSheets.UniverSheetsPlugin); univer.registerPlugin(UniverSheetsUi.UniverSheetsUIPlugin); univer.registerPlugin(UniverSheetsNumfmt.UniverSheetsNumfmtPlugin); univer.registerPlugin(UniverSheetsFormula.UniverSheetsFormulaPlugin); univer.createUnit(UniverCore.UniverInstanceType.UNIVER_SHEET, {}); } // Functionality for the "load" button document.getElementById('load').addEventListener('click', function() { reloadUniver(); // Reload the Univer instance }); </script>

`

Expected behavior

It should be destroyed correctly and no errors should be reported.

Actual behavior

If the actual destruction is executed and dispose is executed, an error will be reported.

Error: [redi]: Injector cannot be accessed after it was disposed

Running environment

Chrome

system message

No response

@KingLiLi KingLiLi closed this as not planned Won't fix, can't repro, duplicate, stale May 30, 2024
@KingLiLi KingLiLi reopened this May 30, 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

Successfully merging a pull request may close this issue.

2 participants