Skip to content

Support Serverpod 3#702

Open
schultek wants to merge 6 commits intomainfrom
feat/serverpod-3
Open

Support Serverpod 3#702
schultek wants to merge 6 commits intomainfrom
feat/serverpod-3

Conversation

@schultek
Copy link
Copy Markdown
Owner

@schultek schultek commented Dec 15, 2025

Description

Resolves #701

Type of Change

Ready Checklist

  • I've read the Contribution Guide.
  • In case this PR changes one of the core packages, I've modified the respective CHANGELOG.md file using
    the semantic_changelog format.
  • I updated/added relevant documentation (doc comments with ///).
  • I added myself to the AUTHORS file (optional, if you want to).

@docs-page
Copy link
Copy Markdown

docs-page bot commented Dec 15, 2025

To view this pull requests documentation preview, visit the following URL:

docs.page/schultek/jaspr~702

Documentation is deployed and generated using docs.page.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Dec 15, 2025

Package Version Report

The following packages have been updated:
jaspr_test : 0.22.3 -> 0.22.4
jaspr : 0.22.3 -> 0.22.4
jaspr_builder : 0.22.3 -> 0.22.4
jaspr_cli : 0.22.3 -> 0.22.4
jaspr_content : 0.5.0 -> 0.5.1
jaspr_lints : 0.6.0 -> 0.6.1
jaspr_serverpod : 0.6.0 -> 0.7.0

@codecov
Copy link
Copy Markdown

codecov bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.94%. Comparing base (6fadec0) to head (de87d00).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #702   +/-   ##
=======================================
  Coverage   60.94%   60.94%           
=======================================
  Files         196      196           
  Lines       11208    11208           
=======================================
  Hits         6831     6831           
  Misses       4377     4377           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

gonft added a commit to gonft/jaspr that referenced this pull request Dec 18, 2025
Refactored jaspr_serverpod to follow upstream PR schultek#702 approach:

- Remove explicit Relic dependency (handled internally by Serverpod 3.0)
- Delete shelf_relic_adapter.dart (95 lines) - use inline conversion
- Update JasprRoute to use serverpod.Request instead of relic.Request
- Add HijackException handling for WebSocket support
- Simplify Response creation with direct Serverpod types
- Update version to 0.7.0

BREAKING CHANGES:
- JasprRoute.build() now takes serverpod.Request (not relic.Request)
- Must hide Request, Response, Handler from jaspr/server.dart import
- Route path changed from /* to /**
- Removed toShelfRequest/toRelicResponse adapters

Migration:
- Update imports: hide Request, Response, Handler from jaspr/server
- Import serverpod types from package:serverpod/serverpod.dart
- Update dependent packages to jaspr_serverpod ^0.7.0
- Remove explicit relic dependency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
@schultek schultek marked this pull request as ready for review December 18, 2025 10:57
@gazialankus
Copy link
Copy Markdown

I would love to see this merged. I would like to to use jaspr on our serverpod 3 app at some point.

There's a very simple ./pubspec.lock conflict: dart_style's version became 3.1.3 in main. Other than that I think this needs a review.

@kivocsa99
Copy link
Copy Markdown

@schultek , do you have any idea when this will be merged and shipped ?

@schultek
Copy link
Copy Markdown
Owner Author

@kivocsa99 I'm waiting for a review from the serverpod team for this PR

@Code-Remote
Copy link
Copy Markdown

I've asked Viktor if anyone of his team could have a look. Can I help resolving the current conflicts?

gonft added a commit to gonft/jaspr that referenced this pull request Feb 25, 2026
Refactored jaspr_serverpod to follow upstream PR schultek#702 approach:

- Remove explicit Relic dependency (handled internally by Serverpod 3.0)
- Delete shelf_relic_adapter.dart (95 lines) - use inline conversion
- Update JasprRoute to use serverpod.Request instead of relic.Request
- Add HijackException handling for WebSocket support
- Simplify Response creation with direct Serverpod types
- Update version to 0.7.0

BREAKING CHANGES:
- JasprRoute.build() now takes serverpod.Request (not relic.Request)
- Must hide Request, Response, Handler from jaspr/server.dart import
- Route path changed from /* to /**
- Removed toShelfRequest/toRelicResponse adapters

Migration:
- Update imports: hide Request, Response, Handler from jaspr/server
- Import serverpod types from package:serverpod/serverpod.dart
- Update dependent packages to jaspr_serverpod ^0.7.0
- Remove explicit relic dependency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
@seanradford
Copy link
Copy Markdown

Hi @schultek, just wanted to check in on this. I'm currently looking to use Serverpod 3 and Jaspr in a new project and so wrapping up this issue would be great for me.

It looks like there are some merge conflicts now - is there anything I can do to help move this forward, or are there plans to get this merged soon? Thanks for the great work on Jaspr!

@schultek
Copy link
Copy Markdown
Owner Author

schultek commented Mar 17, 2026

I'm still waiting on a review from the serverpod team. CC @vlidholt @nielsenko

gonft added a commit to gonft/jaspr that referenced this pull request Mar 19, 2026
Refactored jaspr_serverpod to follow upstream PR schultek#702 approach:

- Remove explicit Relic dependency (handled internally by Serverpod 3.0)
- Delete shelf_relic_adapter.dart (95 lines) - use inline conversion
- Update JasprRoute to use serverpod.Request instead of relic.Request
- Add HijackException handling for WebSocket support
- Simplify Response creation with direct Serverpod types
- Update version to 0.7.0

BREAKING CHANGES:
- JasprRoute.build() now takes serverpod.Request (not relic.Request)
- Must hide Request, Response, Handler from jaspr/server.dart import
- Route path changed from /* to /**
- Removed toShelfRequest/toRelicResponse adapters

Migration:
- Update imports: hide Request, Response, Handler from jaspr/server
- Import serverpod types from package:serverpod/serverpod.dart
- Update dependent packages to jaspr_serverpod ^0.7.0
- Remove explicit relic dependency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
@seanradford
Copy link
Copy Markdown

No sure if it helps / interest. While not fully tested (and I don't think ideal), I have managed to get the branch 'feat/serverpod3' working with Serverpod 3.4.4. To do so I had to create a custom 'JasprRoute' to handle the different Relic vs Shelf request classes.

import 'dart:async';
import 'dart:typed_data';

import 'package:jaspr_serverpod/jaspr_serverpod.dart';
import 'package:serverpod/serverpod.dart';
// ignore: depend_on_referenced_packages
import 'package:shelf/shelf.dart' as shelf;
// ignore: depend_on_referenced_packages
import 'package:stream_channel/stream_channel.dart';

abstract class CustomJasprRoute extends JasprRoute {

  CustomJasprRoute();

  @override
  FutureOr<Result> handleCall(Session session, Request request) async {
    final hijackCompleter =
        Completer<void Function(StreamChannel<List<int>>)>.sync();

    // Fix: Derive the handlerPath correctly
    // jaspr expects handlerPath to be the prefix that is already matched.
    // Usually for a root jaspr app, this is just '/' or whatever path it is mounted at.
    // If request.url is http://localhost:8082/something,
    // and we mount jaspr at root, handlerPath should be ''.
    // Let's just use '/' or '' to avoid the RangeError.
    final String handlerPath = '';

    final shelf.Request shelfRequest = shelf.Request(
      request.method.value,
      request.url,
      protocolVersion: request.protocolVersion,
      headers: request.headers,
      handlerPath: handlerPath,
      body: request.body.read(),
      encoding: request.encoding,
      context: {'session': session, 'request': request},
      onHijack: (callback) => hijackCompleter.complete(callback),
    );
    final shelf.Response shelfResponse;
    try {
      shelfResponse = await handler(shelfRequest);
    } on shelf.HijackException catch (error, stackTrace) {
      if (!shelfRequest.canHijack) {
        final callback = await hijackCompleter.future;
        return Hijack(callback);
      }
      session.log(
        '[jaspr_serverpod] Got a HijackException, but the request was not hijacked.',
        level: LogLevel.error,
        exception: error,
        stackTrace: stackTrace,
      );
      return Response.internalServerError();
    }

    final response = Response(
      shelfResponse.statusCode,
      body: Body.fromDataStream(
        shelfResponse.read().map(Uint8List.fromList),
        encoding: shelfResponse.encoding,
        mimeType: shelfResponse.mimeType != null
            ? MimeType.parse(shelfResponse.mimeType!)
            : null,
        contentLength: shelfResponse.contentLength,
      ),
      headers: Headers.fromMap(shelfResponse.headersAll),
    );

    return response;
  }
}

gonft added a commit to gonft/jaspr that referenced this pull request Apr 11, 2026
Refactored jaspr_serverpod to follow upstream PR schultek#702 approach:

- Remove explicit Relic dependency (handled internally by Serverpod 3.0)
- Delete shelf_relic_adapter.dart (95 lines) - use inline conversion
- Update JasprRoute to use serverpod.Request instead of relic.Request
- Add HijackException handling for WebSocket support
- Simplify Response creation with direct Serverpod types
- Update version to 0.7.0

BREAKING CHANGES:
- JasprRoute.build() now takes serverpod.Request (not relic.Request)
- Must hide Request, Response, Handler from jaspr/server.dart import
- Route path changed from /* to /**
- Removed toShelfRequest/toRelicResponse adapters

Migration:
- Update imports: hide Request, Response, Handler from jaspr/server
- Import serverpod types from package:serverpod/serverpod.dart
- Update dependent packages to jaspr_serverpod ^0.7.0
- Remove explicit relic dependency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 (1M context) <noreply@anthropic.com>
@vlidholt
Copy link
Copy Markdown

Hi! Sorry, this is taking a long time. The Serverpod team has a very tight deadline for our next version of Serverpod, and this PR will need a bit more love to fit really well with how Serverpod works and our upcoming hot reload. We'll get to it after the release! @schultek

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Serverpod 3.0 Relic web server support for jaspr_serverpod

6 participants