microsoft/FASTER · error · FasterException
Functions not provided for session
Error message
Functions not provided for session
What it means
FASTERClientSession.NewSession<Functions> requires the internal _functions field (set by the FASTER wrapper when the session was created) to hold an IFunctions instance. When none was provided, it cannot cast to the requested Functions type, so it throws FasterException instead of a NullReferenceException deep inside FasterKV.
Solutions
- Provide an IFunctions<Key, Value, Input, Output, Context> instance to the FASTERClientSession before calling NewSession.
- Ensure the FASTERClientSession constructor/factory path that sets _functions is used.
- Check _functions for null (or expose a guard) before calling NewSession.
Example fix
// before var clientSession = new FASTERClientSession<Key, Value, Input, Output, Context>(fasterKV, ...); // functions: null clientSession.NewSession<MyFunctions>(); // throws // after var clientSession = new FASTERClientSession<Key, Value, Input, Output, Context>(fasterKV, ..., functions: new MyFunctions()); clientSession.NewSession<MyFunctions>(); // ok
Defensive patterns
Strategy: validation
Validate before calling
if (clientSessionFunctions is null)
throw new InvalidOperationException("Functions must be provided to FASTERClientSession before NewSession");
clientSession.NewSession<MyFunctions>(); Type guard
bool HasFunctions<TK, TV, TI, TO, TC>(FASTERClientSession<TK, TV, TI, TO, TC> s) => s != null /* and functions accessor non-null */;
Try / catch
try
{
var session = clientSession.NewSession<MyFunctions>();
}
catch (FasterException ex) when (ex.Message.Contains("Functions not provided"))
{
// recreate wrapper with functions, then retry
} Prevention
- Require IFunctions in the FASTERClientSession constructor (non-nullable).
- Centralize session creation in a factory that always supplies functions.
- Fail fast at wrapper construction if functions is null.
When it happens
Trigger: Calling NewSession<Functions>() on a FASTERClientSession whose functions were never supplied (e.g. session created without functions, or functions set to null).
Common situations: Constructing the client session wrapper without registering an IFunctions implementation, or clearing functions before opening a session; unit tests using partial stubs that leave _functions null.
Related errors
- Out of order message within session
- Unexpected status of SubscribeKV
- Cannot use BlittableParameterSerializer with non-blittable…
- The inner list is full!
- The list is empty!
AI-assisted analysis of microsoft/FASTER@321d872eab (2026-09-15).
Data as JSON: /api/errors/f137f9d179a52ba5.
Report an issue: GitHub.
Appendix: source
Thrown at cs/src/core/ClientSession/FASTERClientSession.cs:74
SessionVariableLengthStructSettings<Value, Input> sessionVariableLengthStructSettings = null, ReadCopyOptions readCopyOptions = default)
where Functions : IFunctions<Key, Value, Input, Output, Context>
{
return _fasterKV.ResumeSession<Input, Output, Context, Functions>(functions, sessionName, out commitPoint, sessionVariableLengthStructSettings, readCopyOptions);
}
/// <summary>
/// Start a new client session with FASTER.
/// </summary>
/// <param name="sessionName">Name of session (optional)</param>
/// <param name="sessionVariableLengthStructSettings">Session-specific variable-length struct settings</param>
/// <param name="readCopyOptions"><see cref="ReadCopyOptions"/> for this session; override those specified at FasterKV level, and may be overridden on individual Read operations</param>
/// <returns>Session instance</returns>
public ClientSession<Key, Value, Input, Output, Context, Functions> NewSession<Functions>(string sessionName = null,
SessionVariableLengthStructSettings<Value, Input> sessionVariableLengthStructSettings = null, ReadCopyOptions readCopyOptions = default)
where Functions : IFunctions<Key, Value, Input, Output, Context>
{
if (_functions == null)
throw new FasterException("Functions not provided for session");
return _fasterKV.NewSession<Input, Output, Context, Functions>((Functions)_functions, sessionName, sessionVariableLengthStructSettings, readCopyOptions);
}
/// <summary>
/// Resume (continue) prior client session with FASTER, used during
/// recovery from failure.
/// </summary>
/// <param name="sessionName">Name of previous session to resume</param>
/// <param name="commitPoint">Prior commit point of durability for session</param>
/// <param name="sessionVariableLengthStructSettings">Session-specific variable-length struct settings</param>
/// <param name="readCopyOptions"><see cref="ReadCopyOptions"/> for this session; override those specified at FasterKV level, and may be overridden on individual Read operations</param>
/// <returns>Session instance</returns>
public ClientSession<Key, Value, Input, Output, Context, Functions> ResumeSession<Functions>(string sessionName, out CommitPoint commitPoint,
SessionVariableLengthStructSettings<Value, Input> sessionVariableLengthStructSettings = null, ReadCopyOptions readCopyOptions = default)
where Functions : IFunctions<Key, Value, Input, Output, Context>
{
if (_functions == null)View on GitHub (pinned to 321d872eab)