You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Experience] Serverpod trade-offs in user-controlled self-hosted use cases and opinionated design decisions
#5259
This is not an issue report or a question, but I wanted to share my experience with Serverpod in case it is potentially useful for future users and project development.
I truly appreciate the amazing work that was done in this open-source framework alternative to closed-source Firebase. Thank you for your support over the years!
Note
I hope this discussion will be taken as a way to provide useful feedback, not just my specific use case.
This is not an attack or saying "Serverpod is bad and is a trap: avoid it". It aims to provide more constructive feedback that can potentially be useful for both maintainers and consumers (use-case mismatches).
I have filed some issues, and comments referenced them in this discussion instead of repeating info.
Serverpod saved me a significant amount of time, but I have noticed that it can be a bit opinionated by design, which is ideal for many projects.
At least for user-deployed, self-hosted servers (like WordPress, fully open-source), it may require consumers to work around some issues and limitations.
I would be happy to send PRs, but that may take a while until I implement automated tests, become familiar with project guidelines, code style/reviews, and backward compatibility with existing Serverpod projects. Some issues may not be solved easily without a major refactor. Unfortunately, currently I have a deadline, and I'm not able to contribute to the code.
So I will have to delay and accept some hacky workarounds, but frequently using them may send a signal that maybe I should consider more minimal solutions for a specific use case.
This is not a Serverpod issue, but rather an indication that the Serverpod design philosophy can be a bit opinionated in a good way for most apps, but not for all projects.
However, some issues are universal and can be addressed regardless of the use case.
Summary
Details
Advantages: Serverpod is an amazing framework in active development, with a growing community, built-in batteries included, works well for most apps, auth modules, automated migration and model generation, abstracts away ORM and HTTP details, and is less like a typical REST API (comment), convenient, fast to develop, fewer chances of programming errors, support for SQLite and PostgreSQL, cloud storage, straightforward deplotmement, handles configs and secrets.
The ORM + automatic database migration is great and reduces the cognitive load compared to raw SQL.
However:
Many problems have a solution, but there is no one universal solution to every problem. Serverpod is not an exception.
As a consumer, you should at least try Serverpod in MVP (minimum viable product) first before starting to build the production project (if you have not used Serverpod before). This applies to many other frameworks (not just Serverpod).
Features may need custom solutions. Strongly opinionated frameworks (with built-in features beyond just API design or coding style decisions), while they save significant time in the short-term or first months, may get in the way in the long term if not used properly. In many cases, it makes sense to use a more minimal solution (e.g., Dart Frog or Shelf directly) to own and maintain a minimal infrastructure that solves exactly the problem (not more or less).
Maybe there should be a section on the Serverpod website saying "when you should use Serverpod" and "when you should not" (like "Why would I not want to use Arch? " section in Arch Wiki)
For example, I don't think Serverpod is a good option for (probably by design):
public server APIs that may be consumed outside of Flutter apps. e.g., there are some noise fields such as __className__ in response body.
developers prioritizing long-term boring stability, standard HTTP semantics (cache-friendly), control flexibility, owning infrastructure/database (and decisions), low coupling (i.e., moving from Serverpod to another server framework in the future), low overhead, and minimal solutions with fewer Dart and native dependencies (SQLite).
non-Firebase/Supabase alternatives (or built-in solutions that might be incompatible with some custom solutions or require reinventing the wheel or a workaround)
Disabling built-in Serverpod routes
When using the built-in Serverpod auth module, e.g., sign-up routes cannot be disabled without some workarounds (full details #5002). I already worked around this issue, which is straightforward.
Workaround script
// Temporary workaround: https://github.com/serverpod/serverpod/issues/5002import'dart:io';
import'packages.dart';
const _scriptPath ='./scripts/serverpod_generate.dart';
const _clientFilePath ='${Packages.client}/lib/src/protocol/client.dart';
voidmain() async {
final generateProcess =awaitProcess.start('dart', [
'run',
'serverpod_cli',
'generate',
], mode: .inheritStdio);
final exitCode =await generateProcess.exitCode;
if (exitCode !=0) {
stderr.writeln('"serverpod generate" failed');
exit(exitCode);
}
final file =File(_clientFilePath);
if (!file.existsSync()) {
stderr.writeln(
'The serverpod generated Dart file was not found: $_clientFilePath',
);
exit(1);
}
final content =await file.readAsString();
const marker ='https://github.com/serverpod/serverpod/issues/5002';
if (content.contains(marker)) {
stdout.writeln('Workaround already applied. Skipping.');
return;
}
final classRegex =RegExp(
// Disclaimer: The Regex is AI-generatedr'class\s+EndpointEmailIdp\s+extends\s+_i1\.EndpointEmailIdpBase\s*\{'r'\s*EndpointEmailIdp\s*\(_i2\.EndpointCaller caller\)\s*:\s*super\(caller\);\s*',
multiLine:true,
);
final match = classRegex.firstMatch(content);
if (match ==null) {
stderr.writeln('Target class not found. No changes were applied.');
exit(1);
}
const insertion =''' // START: https://github.com/serverpod/serverpod/issues/5002 // This workaround was applied by running "dart $_scriptPath" @override Future<_i1.UuidValue> startRegistration({ required String email, }) async { // Stub implementation to satisfy the Dart compiler. throw UnimplementedError(); } // END''';
final updated = content.replaceFirst(
classRegex,
'${match.group(0)}\n$insertion',
);
await file.writeAsString(updated);
stdout.writeln('Workaround applied successfully.');
}
SQLite (newly added transitive dependency)
After updating to Serverpod beta (3.5.0-beta.9), I encountered another issue:
dart compile exe bin/main.dart ...'dart compile' does not support build hooks, use 'dart build' instead.Packages with build hooks: sqlite3, sqlite3_connection_pool.Failed to compile the Dart program.
It seems that SQLite was added as a transitive dependency.
In a specific use case at least, I don't strictly need SQLite, not even during development, since PostgreSQL installation and database creation are automated in my setup.
This can be workarounded: e.g., by patching the sqlite3 and sqlite3_connection_pool hooks (to remove native libraries) or by accepting the increased bundle size.
Unused code can add more on the surface for more issues, e.g., Flathub may require using the native SQLite library from the runtime rather than rebundling in the app in some review cases if SQLite is already provided, and bundling can be discouraged (flathub/flathub#8362 (comment)) (for strong reasons).
I generate default configs if files are not present, so I should create the files before creating a Serverpod instance (even before starting the server). This means I should depend on some workarounds or reinvent the wheel if I want to use some methods from Serverpod.
Naming & API design
This may seem like a developer's personal style, but for fully user-controlled self-hosted servers, it becomes more important (unlike internal deployments).
For example, I don't want to leak the Serverpod framework name as part of the public API of the app server (e.g., environment variables):
"Public API" here refers to the server public API from a consumer perspective (the user that calls this executable), not the API contract between client and server or HTTP REST API. This is not about acknowledgment or credibility.
That makes it harder to migrate from Dart/Serverpod in the future, and I will have to maintain backward compatibility because the server is self-hosted. It is also confusing for the users to read "SERVERPOD_PASSWORD_" as not many are familiar with Serverpod (cognitive load shifts from developer to user/admin).
Serverpod provides the option to override this in code, but then I will have to implement a custom config system and map it to Serverpod models, which makes the opinionated design slightly less valuable for this case.
I'm not saying that decision is bad, but I'm arguing that Serverpod has some opinionated framework assumptions that do not fit every use case.
For apps where the server deployment is controlled strictly by the app developer, this does not make any difference to the end-user.
HTTP client
Implementation
The reason why I switched from 3.4.8 to 3.5.0-beta.9 is the lack of overriding the underlying HTTP client implementation when using the generated Client.
I should use workarounds such as on TypeError catch(e) when calling any generated client methods. This is an anti-pattern according to Dart (TypeError is a programming bug, see also avoid_catching_errors and documentation of Exception and Error). More details in the comment.
There is an issue with SocketException mapping, and currently we will have to map statusCode: -1 and parse the message manually instead of getting an explicit detailed SocketException. The message is a bit inconsistent when SocketException or http.ClientException is thrown.
Using serverpod_auth_core_flutter solved the core issue, as I don't need the built-in widgets to begin with.
Still, there are other transitive dependencies such as _discoveryapis_commons, google_cloud, sign_in_with_apple_server and more.
Generated Client requires a different instance for each server (addressed in #5134, Serverpod beta)
My client app may connect to multiple self-hosted servers (user controlled) and switch between them (like Telegram account switching).
The current Serverpod-generated Client design requires creating a new instance for each server (e.g., Map<String, Client>). This also creates a new http.Client or underlying platform HTTP client, which does not allow reusing the same HTTP client for different Serverpod Client.
My proposal is to separate the HTTP client from the Serverpod client instance, so the user may use one HTTP client, and then create multiple Serverpod client objects that use that one client, and then the user can use a Serverpod client to make their typical calls.
As for now, each Serverpod's Client also creates an HTTP client internally and hardcoded.
While addressed, the generated Serverpod's Client depends on secure storage, and I consider it more than a pure API client componenet (not stateless).
JWT is an infrastructure detail, something that may change and evolve over time,
whereas business logic typically refer to core domain rules, such as "User must be at least 16 years old to sign up" (business role).
I think this is a very common misunderstanding in this industry, and 4 years ago I used to have an inaccurate understanding or definition of business logic.
This makes me think this code might be AI-generated and/or was a bit rushed. Many of the PRs have AI-generated descriptions, images, etc. Using AI as a tool is fine, but using it as a complete solution without enough human design validation raises some concerns when using the framework.
If AI can get the job done better than all humans (including me), then I will just use it.
AI may blindly depend on common misunderstandings in some online resources if misused or not enough explicit context is provided (which is a pretty common issue).
If I have to assume, this is probably AI-generated code:
We humans often don't spend time repeating the same info twice in the same context/line.
Other transitive dependencies
Technically, they can be replaced if there are any issues, but, e.g., Serverpod by default adds connectivity_plus as a transitive dependency. Can be patched and removed, but in my case, I fixed the issue from core by creating a tiny package (connectivity_plus_linux_portal) which supports Linux Portals instead of direct system D-Bus (comply with Flatpak/Flathub).
Example (unrelated to Serverpod)
finalPlatform _platform;
finalDBusClientFactory _dBusClientFactory;
/// Detects whether the current platform exposes native APIs for mDNS service /// advertising and discovery.Future<bool> supportsPlatformApi() async {
if (_platform.isLinux) {
return_supportsAvahiViaDbus();
}
if (_platform.isWindows) {
return win32.OsVersion.current >= .win10v1903;
}
if (_platform.isIOS || _platform.isMacOS) {
returntrue;
}
if (_platform.isAndroid) {
returnBuild$VERSION.SDK_INT>=Build$VERSION_CODES.R&&SdkExtensions.getExtensionVersion(Build$VERSION_CODES.TIRAMISU) >=17;
}
throwUnsupportedError(
'Unsupported operating system: ${_platform.operatingSystem}',
);
}
Future<bool> _supportsAvahiViaDbus() async {
final client =_dBusClientFactory();
try {
returnawait client.nameHasOwner('org.freedesktop.Avahi');
} onDBusMethodResponseException {
returnfalse;
} finally {
await client.close();
}
}
This approach avoids feature-rich packages that add more on the surface for more issues. For example, when I was a Flutter Quill maintainer, I developed a small plugin (quill_native_bridge) that contains exactly the functionality that flutter_quill needs for rich text pasting.
The previous approach used super_clipboard, which is superior but too overpowered for a simple feature, and it required all consumers to install Rust and made things even harder when it comes to CI, Flatpak, Windows, and different environments or versions. Consumers reproduced too many build failures.
quill_native_bridge is not perfect, but the maintenance effort was cheaper despite the costly initial maintenance effort.
Notice that the exception handling (DBusMethodResponseException) is scoped and does not try to map standard exceptions or catch(e) (all errors, exceptions, and all types) and return false silently for all failures.
Even if it can be replaced or fixed, transitive dependencies and plugins may require some maintenance work for fairly minimal functionality (connected VS not connected).
For example, it uses some new features that I don't need, which may require upgrading dependencies, tools (e.g., fluttercommunity/plus_plugins#3787), or sometimes updating the minimum required OS version.
I personally prefer to use jni, FFI, Win32, and D-Bus with minimal functionality in a tiny local package rather than using a pub.dev package with many functionalities and features I will not need. Plugins like device_info_plus are great if you consume most of its features, but for just detecting an iOS simulator, I would use is_ios_simulator or create a small minimal package for this.
The same goes with flutter_secure_storage, I technically use it, but sometimes it may cause some issues on some platforms (e.g., juliansteenbakker/flutter_secure_storage#920) (even if I override the default implementation ..authSessionManager = FlutterAuthSessionManager()).
I would want the option to change it via abstractions and local packages, but if Serverpod uses it directly (always added as a transitive dependency), I will need to patch it manually (.patch files) or fork it as well.
This is another example #5224, (although easily solvable in this case).
Unix design assumptions
Windows support has significantly improved over the years, but there are still decisions that assume a Unix-like OS (e.g., Serverpod.shutdown).
For the majority of projects and cloud deployments, this is most likely the correct decision.
I personally use Linux desktop over Windows, but at least for LIS, hospitals or private labs may want to use the typical Windows OS and not GNU/Linux or macOS for hosting the server.
That Unix exit code may not work well on Windows when using winsw or nssm. The Dart doc comment says:
/// The handling of exit codes is platform specific./// .../// Due to these facts it is recommended to only use exit codes in the/// range \[0..127\] for communicating the result of running a Dart/// program to the surrounding environment. This will avoid any/// cross-platform issues.
The workaround for this specific case: a custom shutdown method that calls Serverpod's shutdown with exitProcess: false if the instance is initialized (i.e., I may want to exit before starting the server).
Custom app arguments
If custom arguments are being passed to the executable program, they need to be filtered and only pass the arguments that Serverpod recognizes; otherwise, it will use default arguments and ignore them without a fatal error (logs a message).
Workaround
// Workaround: This app supports custom arguments. Serverpod fails// to parse and will use default values if there is an unrecognized argument.// Ideally we should address the core issue, but for now this workaround is sufficient.final withoutAppArgs = args
.where(
(argument) =>_AppArgument.values.firstWhereOrNull(
(appArgument) => appArgument.argument == argument,
) ==null,
)
.toList();
final pod =Serverpod(withoutAppArgs, Protocol(), Endpoints());
Serverpod is more aiming to be a RPC (remote procedure call) over a REST API.
While the style is still RPC-like, it is still using standard HTTP/JSON while hiding these details.
gRPC is fundamentally different:
uses a binary RPC protocol instead of JSON.
uses HTTP/2 instead of HTTP/1
REST-style APIs (with correct HTTP semantics, Cloudflare/CDN setup etc...) can be more cache-friendly by default since they are resource-oriented (e.g., user ID is in the path/query parameter instead of the request body).
Serverpod:
provides all arguments in the request body
does not allow setting headers in the generated client
It still uses the Authorization header internally (generated client)
Technically, we can use a custom API client implementation OR pass default headers to a custom http.Client and pass it to httpClientOverride when creating Serverpod's generated Client but that still does not allow headers per request cleanly
does not support HTTP path/query parameters
For gRPC, it is probably fine (different underlying transport implementation), but Serverpod is still HTTP/JSON, so I would adapt to standard HTTP semantics.
I think Serverpod's design is intentional, but the trade-offs can be documented.
It seems that Serverpod optimizes for fast, rapid development, out-of-the-box type safety, a generated client and/or ORM, automated migrations, and developer convenience, with trade-offs.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
This is not an issue report or a question, but I wanted to share my experience with Serverpod in case it is potentially useful for future users and project development.
I truly appreciate the amazing work that was done in this open-source framework alternative to closed-source Firebase. Thank you for your support over the years!
Note
I hope this discussion will be taken as a way to provide useful feedback, not just my specific use case.
This is not an attack or saying
"Serverpod is bad and is a trap: avoid it". It aims to provide more constructive feedback that can potentially be useful for both maintainers and consumers (use-case mismatches).I have filed some issues, and comments referenced them in this discussion instead of repeating info.
Serverpod saved me a significant amount of time, but I have noticed that it can be a bit opinionated by design, which is ideal for many projects.
At least for user-deployed, self-hosted servers (like WordPress, fully open-source), it may require consumers to work around some issues and limitations.
I would be happy to send PRs, but that may take a while until I implement automated tests, become familiar with project guidelines, code style/reviews, and backward compatibility with existing Serverpod projects. Some issues may not be solved easily without a major refactor. Unfortunately, currently I have a deadline, and I'm not able to contribute to the code.
So I will have to delay and accept some hacky workarounds, but frequently using them may send a signal that maybe I should consider more minimal solutions for a specific use case.
This is not a Serverpod issue, but rather an indication that the Serverpod design philosophy can be a bit opinionated in a good way for most apps, but not for all projects.
However, some issues are universal and can be addressed regardless of the use case.
Summary
Details
Advantages: Serverpod is an amazing framework in active development, with a growing community, built-in batteries included, works well for most apps, auth modules, automated migration and model generation, abstracts away ORM and HTTP details, and is less like a typical REST API (comment), convenient, fast to develop, fewer chances of programming errors, support for SQLite and PostgreSQL, cloud storage, straightforward deplotmement, handles configs and secrets.
The ORM + automatic database migration is great and reduces the cognitive load compared to raw SQL.
However:
Many problems have a solution, but there is no one universal solution to every problem. Serverpod is not an exception.
As a consumer, you should at least try Serverpod in MVP (minimum viable product) first before starting to build the production project (if you have not used Serverpod before). This applies to many other frameworks (not just Serverpod).
Features may need custom solutions. Strongly opinionated frameworks (with built-in features beyond just API design or coding style decisions), while they save significant time in the short-term or first months, may get in the way in the long term if not used properly. In many cases, it makes sense to use a more minimal solution (e.g., Dart Frog or Shelf directly) to own and maintain a minimal infrastructure that solves exactly the problem (not more or less).
Maybe there should be a section on the Serverpod website saying "when you should use Serverpod" and "when you should not" (like
"Why would I not want to use Arch? "section in Arch Wiki)For example, I don't think Serverpod is a good option for (probably by design):
__className__in response body.Disabling built-in Serverpod routes
When using the built-in Serverpod auth module, e.g., sign-up routes cannot be disabled without some workarounds (full details #5002). I already worked around this issue, which is straightforward.
Workaround script
SQLite (newly added transitive dependency)
After updating to Serverpod beta (3.5.0-beta.9), I encountered another issue:
It seems that SQLite was added as a transitive dependency.
In a specific use case at least, I don't strictly need SQLite, not even during development, since PostgreSQL installation and database creation are automated in my setup.
This can be workarounded: e.g., by patching the
sqlite3andsqlite3_connection_poolhooks (to remove native libraries) or by accepting the increased bundle size.Unused code can add more on the surface for more issues, e.g., Flathub may require using the native SQLite library from the runtime rather than rebundling in the app in some review cases if SQLite is already provided, and bundling can be discouraged (flathub/flathub#8362 (comment)) (for strong reasons).
Server config
App-specific config
#633
For now, I handle app-specific config separately.
I generate default configs if files are not present, so I should create the files before creating a
Serverpodinstance (even before starting the server). This means I should depend on some workarounds or reinvent the wheel if I want to use some methods fromServerpod.Naming & API design
This may seem like a developer's personal style, but for fully user-controlled self-hosted servers, it becomes more important (unlike internal deployments).
For example, I don't want to leak the Serverpod framework name as part of the public API of the app server (e.g., environment variables):
Note
"Public API" here refers to the server public API from a consumer perspective (the user that calls this executable), not the API contract between client and server or HTTP REST API. This is not about acknowledgment or credibility.
That makes it harder to migrate from Dart/Serverpod in the future, and I will have to maintain backward compatibility because the server is self-hosted. It is also confusing for the users to read
"SERVERPOD_PASSWORD_"as not many are familiar with Serverpod (cognitive load shifts from developer to user/admin).Serverpod provides the option to override this in code, but then I will have to implement a custom config system and map it to Serverpod models, which makes the opinionated design slightly less valuable for this case.
I'm not saying that decision is bad, but I'm arguing that Serverpod has some opinionated framework assumptions that do not fit every use case.
For apps where the server deployment is controlled strictly by the app developer, this does not make any difference to the end-user.
HTTP client
Implementation
The reason why I switched from
3.4.8to3.5.0-beta.9is the lack of overriding the underlying HTTP client implementation when using the generatedClient.Related issues / PRs:
httppackage should be moved todio#1927 (comment)The previous implementation used raw
dart:ioon IO platforms, andpackage:httpon the web. Consumers may want to use rhttp or cupertino_httpClient Context / Headers
Custom headers cannot be passed, and any data will have to be in the request body only:
x-api-keyin serverpodEndpoint? #4892Error handling
Full Details in this comment: #3283 (comment)
In short:
I should use workarounds such as
on TypeError catch(e)when calling any generated client methods. This is an anti-pattern according to Dart (TypeErroris a programming bug, see also avoid_catching_errors and documentation ofExceptionandError). More details in the comment.There is an issue with
SocketExceptionmapping, and currently we will have to mapstatusCode: -1and parse the message manually instead of getting an explicit detailedSocketException. The message is a bit inconsistent whenSocketExceptionorhttp.ClientExceptionis thrown.Malformed request error handling
#1930
This can spam the server console log.
Auth client transitive dependencies
Using the serverpod_auth_idp_flutter package (in default app template) adds many transitive dependencies such as sign_in_with_apple , google_sign_in, google_fonts (and more), which I don't really need for an LIS that should be independent of external infrastructure (offline).
Using
serverpod_auth_core_fluttersolved the core issue, as I don't need the built-in widgets to begin with.Still, there are other transitive dependencies such as _discoveryapis_commons, google_cloud, sign_in_with_apple_server and more.
Generated(addressed in #5134, Serverpod beta)Clientrequires a different instance for each serverMy client app may connect to multiple self-hosted servers (user controlled) and switch between them (like Telegram account switching).The current Serverpod-generatedClientdesign requires creating a new instance for each server (e.g.,Map<String, Client>). This also creates a newhttp.Clientor underlying platform HTTP client, which does not allow reusing the same HTTP client for different ServerpodClient.My proposal is to separate the HTTP client from the Serverpod client instance, so the user may use one HTTP client, and then create multiple Serverpod client objects that use that one client, and then the user can use a Serverpod client to make their typical calls.As for now, eachServerpod'sClientalso creates an HTTP client internally and hardcoded.While addressed, the generated Serverpod's Client depends on secure storage, and I consider it more than a pure API client componenet (not stateless).
Can the current naming be a bit confusing? Firebase does not use the term
Clientand the authentication is separated:FirebaseAuth.instanceAPI design and AI concerns
Other API naming issues / AI concerns
Depending on the definition of "Business logic", this label can be misleading?
JWT is an infrastructure detail, something that may change and evolve over time,
whereas business logic typically refer to core domain rules, such as "User must be at least 16 years old to sign up" (business role).
I think this is a very common misunderstanding in this industry, and 4 years ago I used to have an inaccurate understanding or definition of business logic.
This makes me think this code might be AI-generated and/or was a bit rushed. Many of the PRs have AI-generated descriptions, images, etc. Using AI as a tool is fine, but using it as a complete solution without enough human design validation raises some concerns when using the framework.
If AI can get the job done better than all humans (including me), then I will just use it.
AI may blindly depend on common misunderstandings in some online resources if misused or not enough explicit context is provided (which is a pretty common issue).
If I have to assume, this is probably AI-generated code:
It is even an anti-pattern in Dart/Flutter repo style: https://github.com/flutter/flutter/blob/master/docs/contributing/Style-guide-for-Flutter-repo.md#avoid-useless-documentation
We humans often don't spend time repeating the same info twice in the same context/line.
Other transitive dependencies
Technically, they can be replaced if there are any issues, but, e.g., Serverpod by default adds
connectivity_plusas a transitive dependency. Can be patched and removed, but in my case, I fixed the issue from core by creating a tiny package (connectivity_plus_linux_portal) which supports Linux Portals instead of direct system D-Bus (comply with Flatpak/Flathub).Example (unrelated to Serverpod)
This approach avoids feature-rich packages that add more on the surface for more issues. For example, when I was a Flutter Quill maintainer, I developed a small plugin (quill_native_bridge) that contains exactly the functionality that
flutter_quillneeds for rich text pasting.The previous approach used super_clipboard, which is superior but too overpowered for a simple feature, and it required all consumers to install Rust and made things even harder when it comes to CI, Flatpak, Windows, and different environments or versions. Consumers reproduced too many build failures.
quill_native_bridgeis not perfect, but the maintenance effort was cheaper despite the costly initial maintenance effort.Notice that the exception handling (
DBusMethodResponseException) is scoped and does not try to map standard exceptions orcatch(e)(all errors, exceptions, and all types) and returnfalsesilently for all failures.Even if it can be replaced or fixed, transitive dependencies and plugins may require some maintenance work for fairly minimal functionality (connected VS not connected).
For example, it uses some new features that I don't need, which may require upgrading dependencies, tools (e.g., fluttercommunity/plus_plugins#3787), or sometimes updating the minimum required OS version.
I personally prefer to use jni, FFI, Win32, and D-Bus with minimal functionality in a tiny local package rather than using a pub.dev package with many functionalities and features I will not need. Plugins like
device_info_plusare great if you consume most of its features, but for just detecting an iOS simulator, I would use is_ios_simulator or create a small minimal package for this.The same goes with
flutter_secure_storage, I technically use it, but sometimes it may cause some issues on some platforms (e.g., juliansteenbakker/flutter_secure_storage#920) (even if I override the default implementation..authSessionManager = FlutterAuthSessionManager()).I would want the option to change it via abstractions and local packages, but if Serverpod uses it directly (always added as a transitive dependency), I will need to patch it manually (
.patchfiles) or fork it as well.This is another example #5224, (although easily solvable in this case).
Unix design assumptions
Windows support has significantly improved over the years, but there are still decisions that assume a Unix-like OS (e.g., Serverpod.shutdown).
For the majority of projects and cloud deployments, this is most likely the correct decision.
I personally use Linux desktop over Windows, but at least for LIS, hospitals or private labs may want to use the typical Windows OS and not GNU/Linux or macOS for hosting the server.
That Unix exit code may not work well on Windows when using winsw or nssm. The Dart doc comment says:
The workaround for this specific case: a custom shutdown method that calls Serverpod's shutdown with
exitProcess: falseif the instance is initialized (i.e., I may want to exit before starting the server).Custom app arguments
If custom arguments are being passed to the executable program, they need to be filtered and only pass the arguments that Serverpod recognizes; otherwise, it will use default arguments and ignore them without a fatal error (logs a message).
Workaround
HTTP semantics and caching
Also, according to this comment #1735 (comment):
While the style is still RPC-like, it is still using standard HTTP/JSON while hiding these details.
gRPC is fundamentally different:
REST-style APIs (with correct HTTP semantics, Cloudflare/CDN setup etc...) can be more cache-friendly by default since they are resource-oriented (e.g., user ID is in the path/query parameter instead of the request body).
Serverpod:
http.Clientand pass it tohttpClientOverridewhen creating Serverpod's generatedClientbut that still does not allow headers per request cleanlyFor gRPC, it is probably fine (different underlying transport implementation), but Serverpod is still HTTP/JSON, so I would adapt to standard HTTP semantics.
I think Serverpod's design is intentional, but the trade-offs can be documented.
It seems that Serverpod optimizes for fast, rapid development, out-of-the-box type safety, a generated client and/or ORM, automated migrations, and developer convenience, with trade-offs.
All reactions