@quenty/loader 6.1.0 → 6.2.0-canary.67644c5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [6.2.0-canary.67644c5.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/loader@6.1.0...@quenty/loader@6.2.0-canary.67644c5.0) (2023-03-05)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * Maids would sometimes error while cancelling threads they were part of. This ensures full cancellation. ([efa28e4](https://github.com/Quenty/NevermoreEngine/commit/efa28e45a2bd7b4e4ae483a9524a421bc89cf81f))
12
+
13
+
14
+
15
+
16
+
6
17
  # [6.1.0](https://github.com/Quenty/NevermoreEngine/compare/@quenty/loader@6.0.1...@quenty/loader@6.1.0) (2023-02-21)
7
18
 
8
19
  **Note:** Version bump only for package @quenty/loader
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quenty/loader",
3
- "version": "6.1.0",
3
+ "version": "6.2.0-canary.67644c5.0",
4
4
  "description": "A simple module loader for Roblox",
5
5
  "keywords": [
6
6
  "Roblox",
@@ -26,5 +26,5 @@
26
26
  "publishConfig": {
27
27
  "access": "public"
28
28
  },
29
- "gitHead": "e084b0cc097ddbcb7c782b8ecbd9c2d619c49354"
29
+ "gitHead": "67644c5978f4a895d352eb7394c9fcb50f9ec4d4"
30
30
  }
package/src2/Maid.lua CHANGED
@@ -115,7 +115,18 @@ function Maid:__newindex(index, newTask)
115
115
  if type(oldTask) == "function" then
116
116
  oldTask()
117
117
  elseif type(oldTask) == "thread" then
118
- task.cancel(oldTask)
118
+ local cancelled
119
+ if coroutine.running() ~= oldTask then
120
+ cancelled = pcall(function()
121
+ task.cancel(oldTask)
122
+ end)
123
+ end
124
+
125
+ if not cancelled then
126
+ task.defer(function()
127
+ task.cancel(oldTask)
128
+ end)
129
+ end
119
130
  elseif typeof(oldTask) == "RBXScriptConnection" then
120
131
  oldTask:Disconnect()
121
132
  elseif oldTask.Destroy then
@@ -201,7 +212,19 @@ function Maid:DoCleaning()
201
212
  if type(job) == "function" then
202
213
  job()
203
214
  elseif type(job) == "thread" then
204
- task.cancel(job)
215
+ local cancelled
216
+ if coroutine.running() ~= job then
217
+ cancelled = pcall(function()
218
+ task.cancel(job)
219
+ end)
220
+ end
221
+
222
+ if not cancelled then
223
+ local toCancel = job
224
+ task.defer(function()
225
+ task.cancel(toCancel)
226
+ end)
227
+ end
205
228
  elseif typeof(job) == "RBXScriptConnection" then
206
229
  job:Disconnect()
207
230
  elseif job.Destroy then
@@ -219,4 +242,4 @@ end
219
242
  ]=]
220
243
  Maid.Destroy = Maid.DoCleaning
221
244
 
222
- return Maid
245
+ return Maid