D4Vinci/Scrapling · error · RuntimeError
No session found with the request session id
Error message
No session found with the request session id
What it means
Raised by SessionManager.fetch when no session is registered under the request's session id. Request objects carry a sid; if that sid was never added via SessionManager.add(), the lookup fails and the crawl aborts for that request.
Source
Thrown at scrapling/spiders/session.py:134
if isinstance(client, _ASyncSessionLogic):
kwargs = request._session_kwargs.copy()
method = cast(SUPPORTED_HTTP_METHODS, kwargs.pop("method", "GET"))
response = await client._make_request(
method=method,
url=request.url,
**kwargs,
)
else:
# Sync session or other types - shouldn't happen in async context
raise TypeError(f"Session type {type(client)} not supported for async fetch")
else:
response = await session.fetch(url=request.url, **request._session_kwargs)
response.request = request
# Merge request meta into response meta (response meta takes priority)
response.meta = {**request.meta, **response.meta}
return response
raise RuntimeError("No session found with the request session id")
async def __aenter__(self) -> "SessionManager":
await self.start()
return self
async def __aexit__(self, *exc) -> None:
await self.close()
def __contains__(self, session_id: str) -> bool:
"""Check if a session ID is registered."""
return session_id in self._sessions
def __len__(self) -> int:
"""Number of registered sessions."""
return len(self._sessions)
View on GitHub (pinned to 5d213a2d47)
Solutions
- Use a session id that was registered: check spider._session_manager.session_ids or `sid in manager` before yielding the Request
- Omit sid to fall back to the default session: Request(url) uses default_session_id
- Register the missing session in configure_sessions with manager.add("<sid>", session)
Example fix
// before
yield Request(url, sid="browser") # 'browser' never registered
// after
def configure_sessions(self, manager):
manager.add("browser", AsyncDynamicSession())
yield Request(url, sid="browser") Defensive patterns
Strategy: validation
Validate before calling
sid = "api"
if sid not in spider._session_manager:
sid = spider._session_manager.default_session_id
yield Request(url, sid=sid) Type guard
def has_session(manager, sid: str) -> bool:
return sid in manager # SessionManager.__contains__ Try / catch
except RuntimeError as e:
if "No session found" in str(e):
yield Request(url) # retry on the default session Prevention
- Define session ids as constants used by both configure_sessions and Request constructors
- Print manager.session_ids during development to verify registrations
- Omit sid to use the default session
When it happens
Trigger: Creating Request(url, sid="api") when no manager.add("api", ...) happened in configure_sessions; passing a sid that was removed via manager.remove/pop before the request was scheduled; typos or renamed session ids between configure_sessions and parse/callback code that yields requests.
Common situations: Sessions defined in one place (configure_sessions) but referenced by string in another (start_requests or parse callbacks); refactoring that renames session ids without updating Request constructors; conditionally-added sessions where the condition was false.
Related errors
- Session '{session_id}' already registered
- No sessions registered
- Session '{session_id}' not found. Available: {available}
- Session type {type(client)} not supported for async fetch
- Error in {self.__class__.__name__}.configure_sessions(): {e}
AI-assisted analysis of D4Vinci/Scrapling@5d213a2d47 (2026-08-14).
Data as JSON: /api/errors/e95c42fb84990ce5.
Report an issue: GitHub.