Upgrading from v0.29 to v0.30.0
This page lists every change in v0.30.0 that can affect code or a deploy that worked on v0.29.13. Each entry says what changed, the old code, and the new code.
- Loud changes stop the build. The error names the change.
- Silent changes compile, but the program behaves differently.
v0.30.0 has no change that is loud only at run time. The full story of each
change is in CHANGELOG.md under v0.30.0.
Loud (fails to compile, the error shows the fix)
New stdlib names
A bare name that two exposing (..) imports now both export is [E1012]
ambiguous, and the error names both modules. The fix is the qualified name,
or a narrower exposing list.
Task.timeout meets Error.timeout
Sky.Core.Task gains timeout (and remaining). Sky.Core.Error already
exports the value timeout : Error. A program that imports both modules with
exposing (..) and writes a bare timeout gets [E1012], and the error
names both modules. Qualify the name: Error.timeout for the error value,
Task.timeout ms task for the deadline.
Live.routeParam and Spa.routeParam meet App.routeParam
Std.Live and Std.Spa gain routeParam for a :param route, the name
Std.App already uses. A program that imports two of these modules with
exposing (..) and writes a bare routeParam gets [E1012], and the error
names the modules. Qualify the name: App.routeParam, Live.routeParam or
Spa.routeParam.
More new names meet your own names
v0.30.0 adds these exports, which can clash with a name that a project module exports:
Std.Sub:viewport,onBreakpoint,onQuerySky.Core.Task:remainingSky.Core.Http:withMinRemainingStd.App:withAdmission
A program that imports one of these modules and a project module that
exports the same name, both with exposing (..), and writes the bare name
gets [E1012] AMBIGUOUS NAME. v0.29.13 accepted it:
import Std.Sub exposing (..)
import Screen exposing (..) -- Screen exports viewport : Int -> String
main =
Log.info (viewport 3)
Qualify the name (Screen.viewport 3, or Sub.viewport for the
subscription), or give one of the two imports an explicit exposing list
(import Std.Sub exposing (Sub)).
An undefined type name is [E1001]
A type name that no module declares (a typo, or a type you removed) was
accepted as an opaque type. An alias that held it compiled, and a use of it
failed with a type mismatch far from the cause. The build now stops with
[E1001] Undefined name: CardView at the name. Fix the name, or declare or
import the type.
Program is one such name. A test file that wrote main : Program above
main = Test.runMain tests now gets [E1001] Undefined name: Program. Write
main : Task Error () instead.
A routed page has the model's page type
An app with App.withRoutes writes the routed page (and the
App.withNotFound page) into its model's page field on every request. The
checker did not compare the two types, so a program like this built and then
answered 500 on every request (or, with two custom types of the same shape,
crashed in the view):
type alias Model = { page : Route, title : String }
app =
App.app { init = init, update = update, view = view, subscriptions = subs }
|> App.withRoutes [ App.route "/" "home", App.routeParam "/item/:id" (\s -> "item:" ++ s) ]
|> App.withNotFound "missing"
Such a program is now refused at App.withRoutes with [E2001] The app's pages have type String(from its routes, its NotFound page or itswithOnNavigatefunction), but the model'spagefield has typeRoute``.
Make every route page and the NotFound page a value of the field's type
(App.route "/" Dashboard, App.routeParam "/item/:id" Detail,
App.withNotFound Missing), or give the field another name if it is not the
app's page. A model with no page field is unchanged.
The check follows a helper that is generic in the model
(withPages routes missing a = a |> App.withRoutes routes |> App.withNotFound missing): each caller is checked with its own model. This is true for a
top-level helper and for a helper bound in a let (a function, a lambda, an
alias of another helper, or a record field), at any depth.
The check also runs on the served app, and this is what makes it complete.
At each use of App.run, App.serve and the target runners (runLive,
runLiveWindow, runSpa, runTui, runCli, runWebview), the checker ties
the served app's page type to its model's page field. The type of the
served app carries the routes' page type through every helper, so any helper
shape is covered: a helper hidden in a user custom type
(type Router … = Router (App … -> App …)), in a record field of one, or in
another module. A project module is app code whatever its name, so a helper
in module Sky.Pages or module Std.Pages is checked the same way. Then the
error points at App.run and says that the app is served there.
The check at the served app is decided for each top-level function that
serves an app, not for each app and not for the whole program. A use of a
runner is checked when the top-level function it is in reaches
App.withRoutes or App.withOnNavigate (directly or through helpers it
uses), or when such a function uses it (the app may be passed to it). Another
entry of the project, another module or a helper that no such function uses
does not change the verdict.
Where the served app can have routes or a navigation hook, the model type
must be known where the app is served. A function that builds and serves an
app with a model type it does not know is refused with [E2001] The routed page type of the app that is served here cannot be checked:
serve parts =
App.app parts |> App.withRoutes routes |> App.withNotFound Missing |> App.run
Give it a type annotation with the model type, or serve the app where its
model type is known (main = App.run app).
The navigation function gets the same rule. After each navigation the
runtime gives the model's page field to the App.withOnNavigate function,
with or without routes. So its argument must have the type of that field:
type alias Model = { page : Route, title : String }
app =
App.app { init = init, update = update, view = view, subscriptions = subs }
|> App.withNotFound { count = 1 }
|> App.withOnNavigate (\r -> Go r.count)
Such a program built and then answered 500 on every request (rt.Coerce: expected struct { Count int }, got main.Main_Route_Detail_V). With an Int
or a String argument it used a wrong value. It is now [E2001] at
App.withOnNavigate. Make the argument a Route (App.withOnNavigate Navigated), or ignore it (App.withOnNavigate (\_ -> Cleared)). In such an
app the App.withNotFound page must also have the field's type, with or
without routes, and the model type must be known where the app is served.
A served app with no App.withRoutes and no App.withOnNavigate is
unchanged when the function that serves it does not reach those builders
and no function that reaches them uses it. Then the runtime does not read
or write its model's page field, so that field and the App.withNotFound
page may have any type. This is true also when another entry of the project
(for example src/Admin.sky beside a routed src/Main.sky), another module
or an unused helper sets routes or a navigation hook.
Because the check is decided for each function, a route-less app served in
the same function as a routed app is checked as a routed one is. Its model's
page field must have the type of its App.withNotFound page. v0.29.13
accepted this program, and it is now [E2001] at App.serve admin:
type alias AdminModel = { page : String, count : Int }
main =
let
site =
App.app { init = init, update = update, view = view, subscriptions = \_ -> Sub.none }
|> App.withRoutes [ App.route "/" Dashboard ]
|> App.withNotFound Missing
admin =
App.app { init = adminInit, update = adminUpdate, view = adminView, subscriptions = \_ -> Sub.none }
|> App.withNotFound 404
in
App.serve admin
|> Task.andThen (\_ -> App.run site)
Moving admin into its own function (serveAdmin) does not change this
while main uses that function, because main reaches App.withRoutes.
Give the page field the NotFound page's type (page : Int), or give the
field another name (screen : String) if it is not the app's page.
The raw APIs get the same rule. Std.Live.Route and Std.Spa.Route now take
the page type (Route page):
- An annotation
List Live.Route(orList Spa.Route) becomesList (Live.Route Page). - A
:paramroute usesLive.routeParam "/item/:id" Detail(orSpa.routeParam).Live.routewith a constructor now gives a route of a function type, which the model'spagefield does not have. Live.config,Spa.withRoutesandSpa.withNotFoundrefuse a page that is not of the model'spagefield type ([E2001]).Live.withOnNavigateandSpa.withOnNavigaterefuse a function whose argument is not of that type. A rawLive.configwith no routes is checked too: itsnotFoundmust have the field's type.- A raw routing helper whose model type is not known
(
withPages config = config |> Spa.withRoutes …) is refused, becauseAppConfig model msgcarries no page type a caller could check. Annotate it with the model type (withPages : Spa.AppConfig Model Msg -> Spa.AppConfig Model Msg), or useApp.withRoutes.
The runtime also checks each page before it writes it into the model. This
check is defence in depth only. A program that the checker accepts cannot
give a page of the wrong type (to the model or to the navigation function), so such a page gets to the runtime only
through a defect: a checker defect (before this release, a helper path that
the checker did not follow, such as a let-bound helper or a helper in a
custom type), or a Go binding
whose Go value does not agree with its declared Sky type. Then the app stops at the first such request with the same
[E2001] text, instead of a panic on every request. A program that passes
sky check and then stops with this error shows a checker defect: report it.
A project module named Shared in a Sky.Spa app
The Sky.Spa split generates a module named Shared (Shared.sky) for the
types and codecs that the client and the server both use. A project module
with the same name would compete with it for one file. A Sky.Spa build that
splits the app (for example --target web:app) with a module named Shared
now stops with "cannot auto-split: the project module Shared has the name
of a module the Sky.Spa split generates". Rename the module (for example to Contract), and change its
module line and every import of it. An app that is not a Sky.Spa app is
unchanged.
HttpRequest has a minRemaining field
Sky.Core.Http.HttpRequest gained minRemaining : Int, read by the new
Http.withMinRemaining (a request refused before it is sent when too little
time is left before a Task.timeout deadline). A request built with
Http.defaultRequest and the with… builders compiles as it did. A request
written as a full record literal is [E2001], naming the missing field.
Before:
{ method = "GET", url = u, body = "", headers = [], timeout = 30000, followRedirects = True, maxRedirects = 10 }
After:
{ method = "GET", url = u, body = "", headers = [], timeout = 30000, followRedirects = True, maxRedirects = 10, minRemaining = 0 }
0 keeps the old behaviour. Better still, start from Http.defaultRequest u.
Silent (compiles, behaves differently)
Added in v0.30.0
These are new features. Code that does not use them works as before, except where a bullet says otherwise.
Std.AdmissionandApp.withAdmission(B1). A policy bounds the/_rpc/<Msg>andApp.apirequests a server runs at the same time. A request over the limit gets 503 withRetry-After, and an optional hook can answer 429 or 503 per request. The hook'sLoadhas asession : Maybe Stringfield, the request's verified session id (the Sky.Live store holds it, or aweb:appbackend verified the session token insky_spaor in the legacysky_sid), so a per-session rule never trusts a raw cookie. There is no default limit: nothing changes until you add a policy or an operator setsSKY_ADMISSION_RPC_LIMIT/SKY_ADMISSION_API_LIMIT.Std.Breaker(B3). A circuit breaker for calls to another service (Breaker.new,Breaker.call). Nothing changes until you import it, except one case: a stdlib module name is reserved, so a project module namedStd.BreakerorStd.Admission(accepted by v0.29.13) is now refused. Rename that module.Sub.viewport,Sub.onBreakpointandSub.onQuery(B4). The viewport width in CSS pixels, the viewport width as one of your breakpoints, and the URL query as aDict String String, on every web target. Nothing changes until asubscriptionsfunction uses them. They are new names inStd.Sub: a module that importsStd.Sub exposing (..)and another moduleexposing (..)that exports the same name gets[E1012]. Qualify the name (Sub.viewport).sky test --coverage,sky coverage reportand a coverage-guidedsky fuzz(B5).sky testwithout--coveragebuilds and runs as before.sky initnow adds.sky-coverage/to a new project's.gitignore. An existing project keeps its.gitignore: add the line yourself if you use--coverage.sky fuzzis now coverage-guided by default: it builds most Msg sequences from earlier ones that reached a newcasearm, and printscase arms reached R/T. The same seed still gives the same run, but not the same sequences as v0.29.13.--unguidedfolds fresh random sequences only, as before.
Fixes in v0.30.0
- A route-less
web:appapp answers an unknown path with its page. AnApp.apporApp.webapp with noApp.withRoutesbuilt forweb:appanswered a path such as/zzwith the plain text404 page not found, so the client never started. The backend now sends the page/serves, with status 404, as Sky.Live sends the app's view with 404. A missing asset is still a plain 404. Nothing to change in your code. If a health check or a test expected the plain-text body, point it at/_sky/healthz. - A route-less Sky.Live app keeps its own
pagefield. An app withApp.withNotFoundand noApp.withRouteshad the NotFound page written into a model field namedpageon every request, whatever its type (apage : Stringfield showed{}). The runtime now writes that field only for an app with routes. Nothing to change in your code. If you renamed a field to avoid this, you can use the namepageagain. An app withApp.withOnNavigateis the exception: the runtime gives itspagefield to the navigation function, so the field, the function's argument and the NotFound page must have one type. - A Sky.Live
htmlpatch on a table keeps its rows. An update that replaced the children of atable,thead,tbody,tfootortrlost the row and cell tags (only their text stayed). Nothing to change in your code. If a test pinned the broken DOM, update it. - A Sky.Spa answer to a page without
X-Sky-Wirekeeps the follow-up writes. A request with noX-Sky-Wireheader (a page from before v0.27.0, or a proxy that removes the header) runs the follow-up Msgs of a server arm on the server. The answer had only the write-set of the first arm, so what the follow-ups wrote (a notice, a result) was lost. The answer now also carries the fields the follow-ups write, and the request carries the fields they read. A current client applies only the first arm's write-set, as before. Nothing to change in your code. App.Route Pagenames the stdlib type in a module with its ownRoute. In a module that declarestype Route, an annotation such asroutes : List (App.Route Page)was read as the module's ownRoute, so the build failed withtype mismatch: Std.App.Route Page vs Main.Route Page. A qualified type name now always names the type of the qualifier's module. This can refuse a program that wrote a qualified name for its own type (List App.Routefor a list of the module's ownRoutevalues): it is now[E2001] type mismatch: Std.App.Route vs Main.Route. Write the bare name (List Route).- A routed page must have the model's page type. A program whose
App.withRoutespages were not of the type of the model'spagefield built and then failed on every request. It is now[E2001], through generic helpers and the rawLive/Sparoute APIs too. The argument of awithOnNavigatefunction must have that type too, with or without routes; see "A routed page has the model's page type" above. - A routed
web:appapp with no server arm serves every route. An app whose arms all run in the client (for exampleApp.webwith aStd.Htmlview andApp.withRoutes) got a backend that served only the static files.GET /was the empty shell andGET /aboutwas a plain404 page not found. Each route path is now 200 with the server-rendered first paint, and an unknown path is thewithNotFoundpage with 404, as the docs say. Such a backend now runs the app'sinitandviewon each page request. - A Sky.Spa module with its own
updatekeeps its server helpers on the server. A sibling module whose function is namedupdatebut is not the app'supdate(for exampleArea.update, reached from the entry's arm or not at all) kept that function in the client copy and dropped the server helpers it calls. The frontend failed withUndefined name. The function now stays on the server like any other function that reaches a server effect, and an arm that calls it runs on the server. Nothing to change in your code. - A failed Sky.Spa backend leg shows its own error only. When the backend
of a
web:app(or other client target) build failed, the output also hadcould not hand the frontend's wasm name to the backend leg: Broken pipe, which hid the real error. That line is gone. Nothing to change in your code. - A Sky.Spa app in a second entry builds from that entry. With
src/Main.skyand the app insrc/Other.sky,sky build src/Other.sky --target web:appbuilt the project'sMaininstead of the app, with no error. It now buildsOther. The generated projects under.split/namesrc/Other.skyas their entry. A project module namedSharedis now refused, because the split generatesShared.sky: rename the module. - A
web:appbuild accepts more multi-module wire types. Three shapes thatsky checkaccepted failed in the Sky.Spa split, and now build: a record alias that names a record alias of another module (type alias CardView = Store.CardView), where a module on the chain has a server function (it failed with[E2001] type mismatch: record vs CardView, or[E1016]); two modules that export one constructor or one record name, both on the wire (P1.MatchedandP2.Matched,[E1012]in the generatedShared; two records namedRefusalwere refused); and a pure module that names a type of a module with a server function, which the model also holds (Wire.Card = { tag : Tags.Tag }, an[E1010]import cycle, also through a chain of modules). Nothing to change in your code. The generatedSharedmodule now names every type, constructor and codec of another module through a generated alias (import Store as SpaTy_Store_,SpaTy_Store_.CardView) and copies no type of a module it can import. A tool or test that read the generated.split/sources and expected a copied type,import <Module> exposing (..)or a bare type name there now finds the qualified form. A shape that would still make the generated modules import each other in a cycle is refused with a message that names the import path, never a raw[E1010].