Skip to content

[core] Only one LambdaRuntime.run() can be called at a time (fix #507) #508

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

Merged
merged 47 commits into from
Jul 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
456569a
make LambdaRuntime a singleton without breaking the API
sebsto Mar 14, 2025
a63a639
fix license header
sebsto Mar 14, 2025
40b6127
convert Mutex to NIOLockedValueBox
sebsto Mar 14, 2025
d474eba
Replace NIOLockedValueBox with Mutex
sebsto Mar 15, 2025
46e76f3
revert replacing NIOLockedValueBox by Mutex
sebsto Mar 15, 2025
299b9bc
remove typed throw (workaround for https://github.com/swiftlang/swift…
sebsto Mar 15, 2025
e3a3851
fix integration tests
sebsto Mar 15, 2025
4ebf24f
Replace NIOLockedValueBox with Mutex
sebsto Mar 15, 2025
f3e65ac
Merge branch 'main' into sebsto/fix_507
sebsto Mar 18, 2025
3aee427
use Atomic instead of Mutex.
sebsto Mar 19, 2025
e445f90
Merge branch 'sebsto/fix_507' of github.com:sebsto/swift-aws-lambda-r…
sebsto Mar 19, 2025
0509eaa
revert `try` on `runtime.init()` in doc
sebsto Mar 19, 2025
aa6395f
revert unwanted change
sebsto Mar 19, 2025
066ab76
revert unwanted change
sebsto Mar 19, 2025
e01b25d
swift-format
sebsto Mar 19, 2025
23c4b64
Merge branch 'main' into sebsto/fix_507
sebsto Mar 20, 2025
57e2396
Update Sources/AWSLambdaRuntime/LambdaRuntime.swift
sebsto Mar 21, 2025
85c988d
Update Sources/AWSLambdaRuntime/LambdaRuntime.swift
sebsto Mar 21, 2025
ab80580
Update Sources/AWSLambdaRuntime/LambdaRuntimeError.swift
sebsto Mar 21, 2025
10304ce
Update Sources/AWSLambdaRuntime/LambdaRuntimeError.swift
sebsto Mar 21, 2025
c1e68fc
Update Tests/AWSLambdaRuntimeTests/LambdaRuntimeTests.swift
sebsto Mar 21, 2025
918492a
Update Tests/AWSLambdaRuntimeTests/LambdaRuntimeTests.swift
sebsto Mar 21, 2025
6ada041
Update Tests/AWSLambdaRuntimeTests/LambdaRuntimeTests.swift
sebsto Mar 21, 2025
06df831
add package visibility to Code
sebsto Mar 21, 2025
50b9df8
swift format
sebsto Mar 24, 2025
fa0fd88
remove print statement
sebsto Mar 24, 2025
4b2b32d
Merge branch 'main' into sebsto/fix_507
sebsto Jun 1, 2025
6aeafbf
Merge branch 'main' into sebsto/fix_507
sebsto Jun 28, 2025
9fb86a7
Merge branch 'sebsto/fix_507' of github.com:sebsto/swift-aws-lambda-r…
sebsto Jun 28, 2025
f7ad7c0
Merge branch 'main' into sebsto/fix_507
sebsto Jun 28, 2025
b60d6e5
apply swift format
sebsto Jun 28, 2025
fbdf503
make LambdaRuntimeError package to be inlinable
sebsto Jun 28, 2025
6353d96
fix example dependencies
sebsto Jun 29, 2025
ee296b4
Merge branch 'main' into sebsto/fix_507
sebsto Jun 29, 2025
e00c1c4
improve logging when task is cancelled
sebsto Jun 29, 2025
b33b6ed
let the lambda runtime set the debug level
sebsto Jun 29, 2025
c5eb4ae
adjust test for task cancellation
sebsto Jun 29, 2025
0b111cd
typos
sebsto Jul 1, 2025
ce23a65
Merge branch 'main' into sebsto/fix_507
sebsto Jul 1, 2025
acf3d7f
simplify check for single instance and single run() invocation
sebsto Jul 1, 2025
9d2cab9
swift-format
sebsto Jul 1, 2025
9737c8a
Merge branch 'main' into sebsto/fix_507
sebsto Jul 3, 2025
7b50167
re-add the check on unique Handler and remove the @unchecked on Lambd…
sebsto Jul 3, 2025
b449a4d
make sure UnsafeTransferBox is reserved to internal usage
sebsto Jul 4, 2025
cf33d7b
use is instead of as? ... != nil
sebsto Jul 4, 2025
f209493
renamae handlerMutex to handlerStorage
sebsto Jul 4, 2025
7ac5292
further rename handlerMutex
sebsto Jul 4, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
swift format
  • Loading branch information
sebsto committed Mar 24, 2025
commit 50b9df8a73d0f6df8f23053111d6ea87e1323ac7
6 changes: 3 additions & 3 deletions Sources/AWSLambdaRuntime/LambdaRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ public final class LambdaRuntime<Handler>: @unchecked Sendable where Handler: St
if original {
throw LambdaRuntimeError(code: .moreThanOneLambdaRuntimeInstance)
}

defer {
_isRunning.store(false, ordering: . releasing)
_isRunning.store(false, ordering: .releasing)
}

try await self._run()
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/AWSLambdaRuntimeTests/LambdaRuntimeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ struct LambdaRuntimeTests {
try await runtime1.run()
}
}

// wait a small amount to ensure runtime1 task is started
try await Task.sleep(for: .seconds(1))

// Running the second runtime should trigger LambdaRuntimeError
await #expect(throws: LambdaRuntimeError.self) {
try await runtime2.run()
}

// cancel runtime 1 / task 1
print("--- cancelling ---")
taskGroup.cancelAll()
Expand Down