Skip to content

Commit

Permalink
fix(reply): dont use utils.Send in boot because it will crash memory
Browse files Browse the repository at this point in the history
  • Loading branch information
atticusofsparta committed Jan 29, 2025
1 parent 162b3ed commit a7e4c53
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
31 changes: 13 additions & 18 deletions src/common/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ function ant.init()
AOS provides a _boot handler that is designed to load Lua code on boot.
This handler OVERRIDES this and replaces it with our ANT state initialization handler.
NOTE: if we use utils.Send here memory blows up for some reason
]]
Handlers.once("_boot", function(msg)
return msg.Tags.Type == "Process" and Owner == msg.From
Expand All @@ -343,28 +344,22 @@ function ant.init()
initialize.initializeANTState(msg.Data)
end, utils.errorHandler)
if not status then
utils.Send(
msg,
notices.addForwardedTags(msg, {
Target = Owner,
Error = res or "",
Data = res or "",
Action = "Invalid-Boot-Notice",
["Message-Id"] = msg.Id,
})
)
ao.send(notices.addForwardedTags(msg, {
Target = Owner,
Error = res or "",
Data = res or "",
Action = "Invalid-Boot-Notice",
["Message-Id"] = msg.Id,
}))
end
end

if Owner then
utils.Send(
msg,
notices.credit({
From = msg.From,
Sender = Owner,
Recipient = Owner,
})
)
ao.send(notices.credit({
From = msg.From,
Sender = Owner,
Recipient = Owner,
}))
end

if AntRegistryId then
Expand Down
1 change: 1 addition & 0 deletions test/evolve.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ describe('aos Evolve', async () => {
},
evolveResult.Memory,
);

assert(evalResult.Output.data);
assert(evalResult.Output.data.includes('info'));
});
Expand Down

0 comments on commit a7e4c53

Please sign in to comment.