Skip to content

serverpod start: adding a future call with parameters generates code that imports a model file that is never written #5760

Closed

Description

@FXschwartz

Under serverpod start, create a future call whose method takes parameters, e.g.

import 'package:serverpod/serverpod.dart';

class ReminderFutureCall extends FutureCall {
  Future<void> remind(Session session, String name) async {}
}

Generation reports success, then compilation fails:

lib/src/generated/protocol.dart:16:8: Error: Error when reading 'lib/src/generated/future_calls_generated_models/reminder_future_call_remind_model.dart': The system cannot find the path specified
lib/src/generated/future_calls.dart:202:28: Error: Type '_iwnpdk7f.ReminderFutureCallRemindModel' not found.

protocol.dart and future_calls.dart reference ReminderFutureCallRemindModel, but lib/src/generated/future_calls_generated_models/ is never created. Every subsequent save hits the same compile error until a .spy.yaml is touched or serverpod generate is run manually. A future call without parameters is unaffected.

Cause

performGenerate only writes future call parameter models when requirements.generateModels is set (analyzers.dart):

if (requirements.generateModels && futureCallModels.isNotEmpty) {
  generatedModelFiles = await ServerpodCodeGenerator.generateSerializableModels(...)

Watch mode sets generateModels: event.modelFiles.isNotEmpty (watch_session.dart:349), which is false for a .dart-only change. A future call with parameters is a model change that arrives via a Dart file, so the gate skips it while the protocol generation that follows still references the model.

Confirmed on a clean main (5410f87) by driving Analyzers.update + Analyzers.performGenerate the way watch mode does:

generateModels: false -> success=true, protocol.dart imports the model, future_calls_generated_models/ does not exist
generateModels: true  -> success=true, future_calls_generated_models/reminder_future_call_remind_model.dart written

Activity

  1. added
    bug
    on Sep 22, 2026
  2. self-assigned this
    on Sep 23, 2026
  3. moved this from Inbox 📫 to In Progress 🔥 in Serverpod Frameworkson Sep 24, 2026
  4. marcelomendoncasoares commented on Sep 24, 2026

    @marcelomendoncasoares
    Collaborator

    As discussed, the fix for this issue will be the replacement of the heuristics we use inside the serverpod_cli to validate whether we should generate or not (like the presence of the strings "Endpoint" or "FutureCall") by a proper analysis of the changed files. It can be a bit slower in cases where multiple files change at once (like when a folder with many files is moved or renamed), but it is a tradeoff of speed for safety. Also, with the analysis server already loaded (after first cycle), it shouldn't represent a significative slowdown.

  5. moved this from In Progress 🔥 to Done 🚀 in Serverpod Frameworkson Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions